[plt-scheme] Slow graphics on NetBSD

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Jul 11 16:15:21 EDT 2003

At Fri, 11 Jul 2003 15:30:11 -0400, Yasir Malik wrote:
>   (= ((get-pixel v) (make-posn (* x pixhght) (* y pixhght))) 0)

Under X, a bitmap resides with the X server. The `get-pixel' operation
works on the client side, however, so the bitmap must be copied from
the X server to the X client.

If you execute many `get-pixel's in a sequence (the common case in most
applications that I see), this copy is usually not bad, because the
bitmap is only transferred once. But if you interleave `get-pixel' with
other drawing commands, then each drawing command invalidates the local
copy of the bitmap, and it's copied again for the next `get-pixel'.

The `get-pixel' implementation could be improved considerably in this
case by copying a smaller portion of the bitmap from server to client.
Copying a smaller part will mean more communication overall in the
common case for `get-pixel', but maybe a good heuristic is to get a
small piece of the bitmap the first time and then get the whole bitmap
if more is needed.

An alternative for your program is to keep an array that mimics the
bitmap. Whenever you draw a big-pixel, set the corresponding entry in
the array, and then consult the array instead of using `get-pixel' for


Posted on the users mailing list.