<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'>Jeff -<BR>
<BR>
I&#8217;m not convinced, either, but I have never seen a real-world test that has shown otherwise. &nbsp;There haven&#8217;t been many such tests, but I have done them myself and several others have done them as well and posted the results on this list. &nbsp;There may be tradeoffs which require a different implementation &#8211; that&#8217;s life in the real world &#8211; but the data (the real, measured data, not theoretical speculation) has always been consistent.<BR>
<BR>
If you want to shrink the file size in this thought experiment that&#8217;s fine, but realize that you are thereby increasing the number of files that need to be opened for a random image request. &nbsp;And each new open file incurs a relatively high cost (directory/disk seek overhead, etc.); those thousands or millions of JPEGs aren&#8217;t just hard to keep track of &#8211; they hurt performance. &nbsp;I have been the keeper of tens of millions of such files, and have seen some of those issues myself.<BR>
<BR>
The example I gave (and my other examples) are, however, primarily intended to help people think about all the aspects of the problem. &nbsp;File access performance in an application environment is a complex issue with many variables and any implementation should be prototyped and tested. &nbsp;All I really care about is that you don&#8217;t think it&#8217;s simple and you try to think through all the consequences of an implementation plan.<BR>
<BR>
I will also admit to being very guilty of not designing for &#8220;low-moderate load&#8221; situations, as I always like my Web sites to be able to survive the situation in which they accidentally turn out to be popular!<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;- Ed<BR>
<BR>
<BR>
On 9/16/08 11:21 AM, &quot;Jeff Hoffmann&quot; &lt;<a href="jeff.hoffmann@gmail.com">jeff.hoffmann@gmail.com</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Ed McNierney wrote:<BR>
&gt;<BR>
&gt; And remember that not all formats are created equal. In order to<BR>
&gt; decompress ANY portion of a JPEG image, you must read the WHOLE file.<BR>
&gt; If I have a 4,000x4,000 pixel 24-bit TIFF image that&#8217;s 48 megabytes,<BR>
&gt; and I want to read a 256x256 piece of it, I may only need to read one<BR>
&gt; megabyte or less of that file. But if I convert it to a JPEG and<BR>
&gt; compress it to only 10% of the TIFF&#8217;s size, I&#8217;ll have a 4.8 megabyte<BR>
&gt; JPEG but I will need to read the whole 4.8 megabytes (and expand it<BR>
&gt; into that RAM you&#8217;re trying to conserve) in order to get that 256x256<BR>
&gt; piece!<BR>
I have a feeling like I'm throwing myself into a religious war, but here<BR>
goes. I think the problem that you have in your estimates is that you're<BR>
using large (well, sort of large) jpegs. When you're using properly<BR>
sized jpegs on modern servers at low-moderate load, you can pretty much<BR>
disregard the processor time and memory issues, and just compare on the<BR>
basis of the slowest component, disk access. 4000x4000 is big &amp; the<BR>
performance isn't going to be good (for the reasons you mention), but he<BR>
never claimed to be using images that big. What he claimed is that he's<BR>
using 1000x1000 jpegs. The 1000x1000 jpegs is pretty critical because<BR>
it's that sweet spot where the decompress time is small, the memory<BR>
demands manageable but the images are large enough that you keep the<BR>
number of tiles down to a minimum for most uses. Those jpegs might be in<BR>
the 200k size range, compared to a 256x256 block = 64k (x3 bands =192k?)<BR>
so he's reading a full 1000x1000 image in the disk space of 1 256x256<BR>
block. If you're serving up 500x500 finished image, you're using at<BR>
least 4 blocks in the geotiff, maybe 9 compared 1-4 with the 1000x1000<BR>
jpeg. You could easily be spending 2x the time reading the disk with<BR>
geotiff as you would be with jpegs. I haven't sat down and done any side<BR>
by side tests, but I can see how they would be competitive for certain<BR>
uses when you look at it that way. Of course there are other issues like<BR>
lossy compression on top of lossy compression, plus you've got to worry<BR>
about keeping track of thousands (millions?) of jpegs, but they're<BR>
probably manageable tradeoffs. Oh, and you don't really get the option<BR>
to have nodata areas with jpegs, either. There's probably other<BR>
drawbacks, too, but I'm not convinced that performance is one of them.<BR>
<BR>
jeff<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>