[gdal-dev] RasterIO Slow

Frank Warmerdam warmerdam at pobox.com
Fri Mar 7 11:18:05 EST 2008


Roman Fedorov wrote:
> Good Afternoon, everybody!
> 
> I noticed that when my program is reading bands of an image - the first calling RasterIO function is slow, and next RasterIO calls (for second and third band) are very fast, almost immediate.
> I checked if it was the fault of the first band, but no matter which band you read, every time olny the first calling of RasterIO function is slow...
> I had this delay on every image drawing,so, since i was opening and closing a GDALDataset every time, i though, maybe the first time of reading a Dataset is slow, because it has to init something - so i put Dataset as static var, and i don't create a new one every time - but as before, the first calling to RasterIO function at every image drawing is slow...
> Do you have any ideas why it happens?

Roman,

What format are you reading?  What size of chunk are you reading?  Pixel
interleaved formats will be slow to read the first band since it will
result in reading the data from disk.  The subsequent bands will be fast
because the file contents will already be in an operating system disk cache.

In the case of some formats, like JPEG, the red, green and blue components
are actually decoded on the first request for one of them, and kept around
in a GDAL buffer so the other bands are usually read very quickly.

In short, this behavior can be the result of a number of factors, and it
does not necessarily indicate any sort of problem.  If you think the first
read is slower than it should be you would need to provide substantial
additional evidence.

PS. opening a file is relatively expensive, so you should try to avoid
reopening it if you can.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list