<HTML>
<HEAD>
<TITLE>Re: [mapserver-users] Ed's Rules for the Best Raster Performance</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Damn, I&#8217;m going to have to get around to unsubscribing soon so I can shut myself up!<BR>
<BR>
Jim, please remember that your disk subsystem does not read only the precise amount of data you request. &nbsp;The most expensive step is telling the disk head to seek to a random location to start reading the data. &nbsp;The actual reading takes much less time in almost every case. &nbsp;Let&#8217;s invent an example so we don&#8217;t have to do too much hard research &lt;g&gt;.<BR>
<BR>
A 7,200-RPM IDE drive has about a 9 ms average read seek time, and most are able to really transfer real data at around 60 MB/s or so (these are very rough approximations). &nbsp;So to read 256KB of sequential data, you spend 9 ms seeking to the right track and then 4 ms reading the data &#8211; that&#8217;s 13 ms. &nbsp;Doubling the read size to 512KB will only take 4 ms (or 30%) longer, not 100% longer. &nbsp;But even that&#8217;s likely to be an exaggeration, because your disk drive &#8211; knowing that seeks are expensive &#8211; will typically read a LOT of data after doing a seek. &nbsp;Remember that &#8220;16MB buffer&#8221; on the package? &nbsp;The drive will likely read far more than you need, so the &#8220;improvement&#8221; you get by cutting the amount of data read in a given seek in half is likely to be nothing at all.<BR>
<BR>
There are limits, of course. &nbsp;The larger your data read is, the more likely it is to be split up into more than one location on disk. &nbsp;That would mean another seek, which would definitely hurt. &nbsp;But in general if you&#8217;re already reading modest amounts of data in each shot, reducing the amount of data read by compression is likely to save you almost nothing in read time and cost you something in decompression time (CPUs are fast, so it might not cost much, but it will very likely require more RAM, boosting your per-request footprint, which means you&#8217;re more at risk of starting to swap, etc.).<BR>
<BR>
And remember that not all formats are created equal. &nbsp;In order to decompress ANY portion of a JPEG image, you must read the WHOLE file. &nbsp;If I have a 4,000x4,000 pixel 24-bit TIFF image that&#8217;s 48 megabytes, and I want to read a 256x256 piece of it, I may only need to read one megabyte or less of that file. &nbsp;But if I convert it to a JPEG and compress it to only 10% of the TIFF&#8217;s size, I&#8217;ll have a 4.8 megabyte JPEG but I will need to read the whole 4.8 megabytes (and expand it into that RAM you&#8217;re trying to conserve) in order to get that 256x256 piece!<BR>
<BR>
Paul is right &#8211; sometimes compression is necessary when you run out of disk (but disks are pretty darn cheap &#8211; the cost per megabyte of the first hard drive I ever purchased (a Maynard Electronics 10 MB drive for my IBM PC) is approximately 450,000 times higher than it is today). &nbsp;If you are inclined toward JPEG compression, read about and think about using tiled TIFFs with JPEG compression in the tiles; it&#8217;s a reasonable compromise that saves space while reducing the whole-file-read overhead of JPEG.<BR>
<BR>
Where the heck is that unsubscribe button?<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;- Ed<BR>
<BR>
<BR>
On 9/15/08 9:23 PM, &quot;Paul Spencer&quot; &lt;<a href="pspencer@dmsolutions.ca">pspencer@dmsolutions.ca</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Jim, you would think that ;) &nbsp;However, in practice I wouldn't expect<BR>
the disk access time for geotiffs to be significantly different from<BR>
jpeg if you have properly optimized your geotiffs using gdal_translate<BR>
-co &quot;TILED=YES&quot; - the internal structure is efficiently indexed so<BR>
that gdal only has to read the minimum number of 256x256 blocks to<BR>
cover the requested extent. &nbsp;And using gdaladdo to generate overviews<BR>
just makes it that much more efficient.<BR>
<BR>
Even if you are reading less physical data from the disk to get the<BR>
equivalent coverage from jpeg, the decompression overhead is enough to<BR>
negate the difference in IO time based on Ed's oft quoted advice (and<BR>
other's experience too I think). &nbsp;The rules that apply in this case<BR>
seem to be 'tile your data', 'do not compress it' and 'buy the fastest<BR>
disk you can afford'.<BR>
<BR>
Compression is useful and probably necessary if you hit disk space<BR>
limits.<BR>
<BR>
Cheers<BR>
<BR>
Paul<BR>
<BR>
On 15-Sep-08, at 5:48 PM, Jim Klassen wrote:<BR>
<BR>
&gt; Just out of curiosity, has anyone tested the performance of Jpegs<BR>
&gt; vs. GeoTiffs?<BR>
&gt;<BR>
&gt; I would expect at some point the additional disk access time<BR>
&gt; required for GeoTiffs (of the same pixel count) as Jpegs would<BR>
&gt; outweigh the additional processor time required to decompress the<BR>
&gt; Jpegs. (Also the number of Jpegs that can fit in disk cache is<BR>
&gt; greater than for similar GeoTiffs.)<BR>
&gt;<BR>
&gt; For reference we use 1000px by 1000px Jpeg tiles (with world files).<BR>
&gt; We store multiple resolutions of the dataset, each in its own<BR>
&gt; directory. We start at the native dataset resolution, and half that<BR>
&gt; for each step, stopping when there are less than 10 tiles produced<BR>
&gt; at that particular resolution. (I.e for one of our county wide<BR>
&gt; datasets 6in/px, 1ft/px, 2ft/px, ... 32ft/px). A tileindex is then<BR>
&gt; created for each resolution (using gdaltindex followed by shptree)<BR>
&gt; and a layer is created in the mapfile for each tileindex and<BR>
&gt; appropriate min/maxscales are set. The outputformat in the mapfile<BR>
&gt; is set to jpeg.<BR>
&gt;<BR>
&gt; Our typical tile size is 200KB. There are about 20k tiles in the 6in/<BR>
&gt; px dataset, 80k tiles in the 3in/px dataset (actually 4in data, but<BR>
&gt; stored in 3in so it fits with the rest of the datasets well). I have<BR>
&gt; tested and this large number of files in a directory doesn't seem to<BR>
&gt; effect performance on our system.<BR>
&gt;<BR>
&gt; Average access time for a 500x500px request to mapserver is 300ms<BR>
&gt; measured at the client using perl/LWP and about 220ms with shp2img.<BR>
&gt;<BR>
&gt; Machine is mapserver 5.2.0/x86-64/2.8GHz Xeon/Linux 2.6.16/ext3<BR>
&gt; filesystem.<BR>
&gt;<BR>
&gt; Jim Klassen<BR>
&gt; City of Saint Paul<BR>
&gt;<BR>
&gt;&gt;&gt;&gt; &quot;Fawcett, David&quot; &lt;<a href="David.Fawcett@state.mn.us">David.Fawcett@state.mn.us</a>&gt; 09/15/08 1:10 PM &gt;&gt;&gt;<BR>
&gt; Better yet,<BR>
&gt;<BR>
&gt; Add your comments to:<BR>
&gt;<BR>
&gt; <a href="http://mapserver.gis.umn.edu/docs/howto/optimizeraster">http://mapserver.gis.umn.edu/docs/howto/optimizeraster</a><BR>
&gt;<BR>
&gt; and<BR>
&gt;<BR>
&gt; <a href="http://mapserver.gis.umn.edu/docs/howto/optimizevector">http://mapserver.gis.umn.edu/docs/howto/optimizevector</a><BR>
&gt;<BR>
&gt; I had always thought that all we needed to do to make these pages<BR>
&gt; great<BR>
&gt; was to grok the list for all of Ed's posts...<BR>
&gt;<BR>
&gt; David.<BR>
&gt;<BR>
&gt; -----Original Message-----<BR>
&gt; From: <a href="mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a><BR>
&gt; [<a href="mailto:mapserver-users-bounces@lists.osgeo.org">mailto:mapserver-users-bounces@lists.osgeo.org</a>] On Behalf Of Brent<BR>
&gt; Fraser<BR>
&gt; Sent: Monday, September 15, 2008 12:55 PM<BR>
&gt; To: <a href="mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><BR>
&gt; Subject: [mapserver-users] Ed's Rules for the Best Raster Performance<BR>
&gt;<BR>
&gt;<BR>
&gt; In honor of Ed's imminent retirement from the Mapserver Support Group,<BR>
&gt; I've put together &quot;Ed's List for the Best Raster Performance&quot;:<BR>
&gt;<BR>
&gt;<BR>
&gt; #1. Pyramid the data<BR>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- use MAXSCALE and MINSCALE in the LAYER object.<BR>
&gt;<BR>
&gt; #2. Tile the data (and merge your upper levels of the pyramid for<BR>
&gt; fewer<BR>
&gt; files).<BR>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- see the TILEINDEX object<BR>
&gt;<BR>
&gt; #3. Don't compress your data<BR>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- avoid jpg, ecw, and mrsid formats.<BR>
&gt;<BR>
&gt; #4. Don't re-project your data on-the-fly.<BR>
&gt;<BR>
&gt; #5. Get the fastest disks you can afford.<BR>
&gt;<BR>
&gt;<BR>
&gt; (Ed, feel free to edit...)<BR>
&gt;<BR>
&gt; Brent Fraser<BR>
&gt; _______________________________________________<BR>
&gt; mapserver-users mailing list<BR>
&gt; <a href="mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><BR>
&gt; <a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><BR>
&gt; _______________________________________________<BR>
&gt; mapserver-users mailing list<BR>
&gt; <a href="mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><BR>
&gt; <a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; mapserver-users mailing list<BR>
&gt; <a href="mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><BR>
&gt; <a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><BR>
<BR>
<BR>
__________________________________________<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Paul Spencer<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Chief Technology Officer<BR>
&nbsp;&nbsp;&nbsp;&nbsp;DM Solutions Group Inc<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.dmsolutions.ca/">http://www.dmsolutions.ca/</a><BR>
<BR>
_______________________________________________<BR>
mapserver-users mailing list<BR>
<a href="mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><BR>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>