Random APC findings

Events happening in the community are now at Drupal community events on www.drupal.org.
kristofferwiklund's picture

I was playing with APC object cache and was wondering if the key length affected the object size stored in APC. I Google and didn't find anything.

So I did some testing myself and it seems that the size of 656b per object is consistent when both key less that ~400 character and value is also less than ~400 character.

So doing some optimization/shorting of the key is not necessary if you have a key shorter than ~400 character.

Also the time to fetch data is not changing if the key has length 10 och 200 character. It takes the same time (+/-0.5%) to fetch 10 000 000 random objects (of a collection on 10 000 objects).

(Sorry if you see this as spam, but I wanted to let other know my findings and this was the best place I could come up with.)

Comments

Thanks for the great info.

mherchel's picture

Thanks for the great info. This is definitely not spam :)

With APC being in shared

fgm's picture

With APC being in shared memory with PHP, it should not change significantly: you will probable encounter more visible differences with cache systems involving network transmission, notably Memcached.

Yes it "should" not. But you

kristofferwiklund's picture

Yes it "should" not. But you never know until you have tested. :)

Because in my setup I am doing some calculation with a c program via exec command. And the result was populated the apc object cache. And my cmd-line, the key, was around 80-120 character long. I could remove spaces and other redundant character to half the size of the key. But with my findings it doesn't matter. So doing premature optimization was bad. Because doing the minimization of the key did nothing for the memory and speed for fetching data. It only used up cpu for making key shorter for no reason.

So having longer key is for me better because now I can copy the key from APC statistics site and run i manually.

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: