Dual Raster Buffers

The previous page discussed using multiple threads to efficiently process a band of our image. In a "real" application, something must be done with the raw bitmap produced by the rasterizer -- typically this means compressing, formatting and writing the bitmap to disk. While this is going on the rasterizer is idle.

single buffer and formatting

The "peach" bar represents time to rasterize a band and the green bar represents the time to compress, format and write it to disk.

If one has sufficient RAM available (to avoid swapping to disk) it is possible to allocate a second raster buffer and start the rasterizer filling the second buffer while the formatting thread is reading and processing data from the first buffer.

dual buffers alternately filled

Assuming the formatter is not consuming all of the CPU's resources, the overall throughput can be measurably improved.

dual buffer and formatter overlap

To test this assumption, our sample application, gds2tiff, includes the ability to define two (or more) raster buffers and to switch between them while also running a tiff formatter which we built into the gdsriplib.

Our benchmarks (see Benchmark Page 2 and Page 3) show about a 1.25 factor improvement in overall throughput when two raster buffers are used. Your improvement factor will vary on the relative compute load of the rasterizer and formatter and on how the formatter code is constructed.




ARTWORK CONVERSION SOFTWARE, INC.                  Company Profile
417 Ingalls St.,     Santa Cruz, CA 95060         Tel (831) 426-6163     Fax 426-2824               email: info@artwork.com