eThreads2 update

Saturday, December 11, 2004, at 10:22AM

By Eric Richardson

Technical stuff to follow. Avert your eyes if you'd like...

Even though you haven't seen much change out front here, there's been some cool stuff happening on the eThreads2 backend. I mentioned earlier in the week that I had added a memory cache. Well, since then that's been rewritten and reworked to be a transparent part of my normal cache structure. There's still some work to do, but I'm going to throw that after the break.

I just got ping support working again, so now my #1 target is comments. Alan's been getting on me about that, letting me know how I've missed his wisdom without them.

Click the post title to read more...

It still needs some work: right now it's not size limited, since the only size limiting cache module I can find seems to be Cache::SizeAwareMemoryCache. That module looks good from the surface, but then you find it's using Storable's dclone(). Using that my performance (running off my laptop, 100 requests, 5 concurrent) drops from 3.72 requests per second to 1.22req/sec. That's huge. Here's a little bit of the profiling from Devel::DProf (these numbers are from 100 executions):

%Time ExclSec #Calls sec/call Csec/c  Name
 41.7   20.93  81578   0.0003 0.0003  Storable::dclone
 4.04   2.025  74794   0.0000 0.0003  Cache::BaseCache::get_object
 3.25   1.632  70364   0.0000 0.0000  Cache::MemoryBackend::get_size
 2.83   1.421 119091   0.0000 0.0000  eThreads::Object::Switchboard::__ANON__
 2.63   1.320   2015   0.0007 0.0114  Cache::CacheSizer::_build_cache_meta_data

As you can see, dclone chews up 42% of the runtime by itself. Assorted other cache routines occupy 11 of the top 15 exclusive times (time spent directly in that sub). Compare that to Cache::FastMemoryCache, which I'm using now (but which doesn't size limit):

%Time ExclSec #Calls sec/call Csec/c  Name
 6.43   1.199  52800   0.0000 0.0000  eThreads::Object::GHolders::_exists
 6.36   1.186  43500   0.0000 0.0001  eThreads::Object::GHolders::exists
 5.11   0.953 117711   0.0000 0.0000  eThreads::Object::Switchboard::__ANON__
 4.33   0.808   4000   0.0002 0.0002  eThreads::Object::Format::Markdown::_HashHTMLBlocks
 4.30   0.802 138900   0.0000 0.0000  eThreads::Object::GHolders::GHolder::has_child

That's more my style. I like knowing that my code's the slow part. I can improve on that, but I can't really improve on naturally slow routines, like dclone().