Changes between Initial Version and Version 1 of UserDocs/GdalWarp


Ignore:
Timestamp:
Aug 1, 2007, 11:01:47 AM (17 years ago)
Author:
maphew
Comment:

how -wm and CACHEMAX work

Legend:

Unmodified
Added
Removed
Modified
  • UserDocs/GdalWarp

    v1 v1  
     1
     2
     3=== Will increasing RAM increase the speed of gdalwarp? ===
     4
     5Adding ram will almost certainly increase the speed.  That’s not at all the same as saying that it is worth it, or that the speed increase will be significant. Disks are the slowest part of the process.
     6
     7By default gdalwarp won't take much advantage of RAM. Using the flag "-wm 500" will operate on 500MB chunks at a time which is better than the default. To increase the io block cache size may also help.  This can be done on the command like:
     8{{{
     9gdalwarp --config GDAL_CACHEMAX 500 -wm 500 ...
     10}}}
     11
     12This uses 500MB of RAM for read/write caching, and 500MB of RAM for working buffers during the warp.  Beyond that it is doubtful more memory will make a substantial difference.
     13
     14Check CPU usage while gdalwarp is running.  If it is substantially less than 100% then you know things are IO bound.  Otherwise they are CPU bound.
     15
     16
     17==== Warp and Cache Memory: Technical Details ====
     18
     19The GDAL_CACHEMAX affects the amount of space reserved for the low
     20level io buffers.  When blocks are read from disk, or written to disk,
     21they are cached in a global block cache by the `GDALRasterBlock` class.
     22Once this cache exceeds `GDAL_CACHEMAX` old blocks are flushed from the
     23cache.
     24
     25You can think of this as primarily an IO cache, and it mostly benefits
     26you when you might need to read or write file blocks more than once.
     27This could occur, for instance, in a scanline oriented input file which
     28is processed in multiple chunks (horizontally) by gdalwarp.
     29
     30The -wm flag affects the warping algorithm.   The warper will total up
     31the memory required to hold the input and output image arrays and any
     32auxilary masking arrays and if they are larger than the "warp memory"
     33allowed it will subdivide the chunk into smaller chunks and try again.
     34
     35If the -wm value is very small there is some extra overhead in doing many
     36small chunks so setting it larger is better but it is a matter of
     37diminishing returns.
     38
     39Overall, there is only so much more memory can do for you.
     40
     41To get a better sense of how things are working, you might want to
     42try running in debug mode.  For instance:
     43{{{
     44  gdalwarp --debug on abc.tif def.tif
     45}}}
     46When things shut down you may see messages like:
     47{{{
     48  GDAL: 224 block reads on 32 block band 1 of utm.tif.
     49}}}
     50In this case it is saying that band 1 of utm.tif has 32 blocks, but
     51that 224 block reads were done, implying that lots of data was
     52having to be re-read, presumably because of a limited io cache.
     53
     54You will also see messages like:
     55{{{
     56GDAL: GDALWarpKernel()::GWKNearestNoMasksByte()
     57Src=0,0,512x512 Dst=0,0,512x512
     58}}}
     59The Src/Dst windows show you the "chunk size" being used.  In this
     60case my whole image which is very small.  If you find things are being
     61broken into a lot of chunks increasing -wm may help somewhat.
     62
     63But far more important than memory are ensuring you are going through
     64an optimized path in the warper.  If you ever see it reporting
     65`GDALWarpKernel()::GWKGeneralCase()` you know things will be relatively
     66slow.  Basically, the fastest situations are nearest neighbour resampling
     67on 8bit data with no nodata or alpha masking in effect.
     68
     69-----
     70Sources:
     71   * [Gdal-dev] Will increasing the RAM on a server increase the speed of gdalwarp? - http://lists.maptools.org/pipermail/gdal-dev/2007-July/013566.html
     72