?

Log in

No account? Create an account
Cache::Cache - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Cache::Cache [Feb. 23rd, 2003|12:21 pm]
Brad Fitzpatrick
[Tags|, ]

I've been reading the code for the Cache::Cache Perl module, and I'm not terribly impressed.

While I don't mind object masturbation, this is a little excessive.

But what concerns me most is that the purge operation (to expire objects which are too old) is O(n). Worse, purge is conditionally invoked (via 3 layers of indirection, mind you) on all get calls! Do you see how fucked this is? A cache retrieval operation should not be O(n).

My caching module for LiveJournal, though not as abstract as the Cache::Cache family, at least keeps data structures around to be able to efficiently clean itself.

From what I can tell, the problem with Cache::Cache is that its "Backend" abstraction needs to know how to purge itself.

Now--- a dilemna: do I steal the shared memory bits I want from Cache::Cache, or help them fix their inefficiencies? Unfortunately, the state of shared memory on Linux is pathetic. Stupid low limits. They're probably tweakable though... need to learn.

The CREDITS file for Cache::Cache lists 31 people. This is good... it means the maintainer takes patches. But have none of those 31 people noticed the purging operation sucks? I'd like to think I'm really smart, but perhaps I'm just stupid and am missing something. Anybody know that code? It's small... somebody else should go audit it and tell me if I'm on crack or not.

Update: Mailed the project maintainer, asking if I'm reading it right, and offering help fixing it if needed.
LinkReply

Comments:
[User Picture]From: scsi
2003-02-23 08:09 pm (UTC)
Is "Object Masturbation" an offical programmers term? heh!
(Reply) (Thread)
From: peagles
2003-02-25 05:43 am (UTC)

Linux shared memory

When I installed Oracle 9i onto one of my SuSE boxes I needed to increase the shared memory. The options were to either rebuild the kernel or do this:

Check the current setting:

cat /proc/sys/kernel/shmmax

I needed it setting to 500000000:

sysctl -w kernel.shmmax=500000000

That did the trick for me.
(Reply) (Thread)
[User Picture]From: brad
2003-02-25 08:52 am (UTC)

Re: Linux shared memory

Thanks! Saved me some research. :-)
(Reply) (Parent) (Thread)