Why I don't like resorting to caching

April 4, 2006

One of my little twitches is that I really don't like putting caching in my programs. It's not because cache invalidation is hard, although it is. It's because resorting to caching is an admission of defeat: it's admitting that I can't make the actual code go fast enough.

In other words, I've failed to write code that's fast enough. I don't think any programmer likes to fail; certainly I don't. I don't like it even when it's not entirely my fault; for example, when the underlying language features and libraries aren't fast enough.

(Of course, sometimes the problem is intrinsically slow no matter how much you optimize. I don't feel bad about those; that's just running into a physical limitation.)

Caching is a compromise; it's a tradeoff of a quick fix against the right fix, however much effort the right fix may take. Of course, that's the perfection trap singing its siren song to me.

The net result is that adding caching too often feels like slathering a bright coat of paint on a rickety house and hoping that no one notices. Doing that sort of thing always leaves me feeling grumpy and dissatisfied.

(And of course one has to measure the overhead of caching, cache checking, and cache invalidation, just to make sure that the cache is actually speeding things up. Benchmarking: enough tedium for the whole family.)

Written on 04 April 2006.
« An ugly spam attempt
The other dynamic linking tax »

Page tools: View Source.
Search:
Login: Password:

Last modified: Tue Apr 4 03:48:52 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.