The window server has a cool feature in OS X 10.1 that isn't enabled by
default (though it will be in an upcoming update, as I understand it): window
buffer compression.
A little background. Under OS X, the contents of each window are saved in a
buffer, so that they can be updated instantly, and also so that the cool
transparency effects in Aqua are possible. This is a good thing, to have a
fully buffered window manager -- however, it uses a lot of memory.
In 32 bit mode ("Millions" in System Preferences), a window that is 800
pixels wide by 600 pixels high uses up 1.9mb of RAM. When you consider that
there are usually over 100 windows open when you're using OS X (not all
windows are visible), you start to realize that this can start to add up in
terms of RAM usage.
The more windows you open, the more RAM they use up, the more that virtual
memory will have to page in and out while you use your applications to do
work. This can cause slow-downs as the disk grinds to do the virtual memory
paging.
So what Apple did was they implemented a compression mechanism into the
window server. When a window's contents haven't changed for a given period of
time, the window server compresses them, so they take up less memory. Since
it uses a compression method that doesn't require the buffer to be fully
decompressed to do compositing (dragging a window around, updating the
screen, etc.), you won't notice a slowdown with this compression turned on.
In fact, because less memory is being used up by the window buffers, more RAM
will be available for your applications, with will mean less virtual memory
paging, and may in fact result in speeding up your machine. Additionally,
since less data needs to be read (it is compressed, after all!), things like
updating windows may be faster as well.
If you are a power user who has lots of windows open, you might consider
giving this hack a shot. I'm using it, and getting compression ratios of
about 8.5:1 (in other words, my window buffers are using 8x less RAM than
they normally would).
Now then, onto the hack! First, open up the Terminal application (found in
/Applications/Utilities/) and type:
sudo pico /Library/Preferences/com.apple.windowserver.plist
(you'll need to enter your admin password in order to proceed)
Move the cursor down below the first <dict> tag, and paste the following text
in:
<key>BackingCompression</key>
<dict>
<key>compressionScanTime</key>
<real>5.000000000000000e+00</real>
<key>minCompressableSize</key>
<integer>8193</integer>
<key>minCompressionRatio</key>
<real>1.100000023841858e+00</real>
</dict>
Then hit Control-X to exit pico (hitting the Y key to save the changes before
exiting when it asks you), then log out and back in again, and ta da!
Compressed window buffers. Enjoy...
If you want to verify that your window compression is working, install the OS
X 10.1 developer tools, and run the QuartzDebug app
(/Developer/Applications/), then click on the "Show window list" button.
Windows that have compressed buffers will have a C next to the size of the
window's buffer in the kByte column of the window list.
Some people are a bit concerned that enabling this compression might slow
things down; that's actually not true. It will actually be faster, for the
two reasons I mentioned. First, less swapping (which will happen somewhat,
regardless of how much RAM you have).
Secondly, consider that most modern CPUs are memory bandwidth-bound. When you
need to update a window with a 200K buffer, you have to read in 200K of data,
then write out 200K of data.
The vast majority of the time spent doing this copying involves the CPU just
sitting and spinning waiting for data. If you use the compressed buffer, and
a reasonable 10:1 compression ratio, you only need to read in 20K of data,
running it by a simple algorithm, and write out 200K of data.
Since your are 10x less memory bound, and since you're using CPU cycles that
would have been wasted anyway, you are faster. This is the same principle
behind RLE blitters, etc.
--
Regards
Roo
==============================================================
Posted with Hogwasher. Mac first, Mac only:
http://www.asar.com/cgi-bin/product.pl?58/hogwasher.html
==============================================================