Thursday, April 13, 2006

Profiling and Optimisation

I've managed to spend some time profiling. It turns out that it makes things much easier if everything is put in a package - then you can do slime-profile-package rather than fiddling with profiling each function individually.

The first results shows that we're spending most of our time talking through CFFI to get values of variables. This turned out to be mostly things like *font* and *mouse-x*. So I've added a system to allow easy updating of these variables through a couple of macros - define-updateable-var and update-var that uses the symbol plist to record a function to execute when updating the variable. Now I only calculate colors on initialisation and grab the updated version of things like *mouse-x* once per frame. This has resulted in much better performance - the fan on my laptop doesn't turn on while running it anymore and it seems to hover around 30% of CPU usage. I've also inlined draw-cell which made quite a big difference.

The new profile shows a much more evenly distributed set of function calls.

I'm going to be spending some time now playing around with cl-emb and cl-who to generate a photo-album style website.