Example:
$arr = array();
for($i = 5; $i < 300000; $i++)
$arr[$i] = 'foo';
apc_store('data', $arr);
It takes like 15 seconds. To get the data it takes around 0.7s.
But if I serialize the data with php and store it like that with apc_store('data', serialize($arr));
it takes only 1 second.
To get the serialized data and then unserialize it, it takes a little more than 0.6s
Why is APC so slow?
apc_sma_info() provides one interesting information which, maybe, could explain why happens.
Executing apc_store() with a non-serialized data produces to me, in block_lists index the following values:
Array
(
[0] => Array
(
[size] => 608
[offset] => 33152
)
[1] => Array
(
[size] => 5589032
[offset] => 11211992
)
[2] => Array
(
[size] => 2175976
[offset] => 31378408
)
)
While serializing them manually produces:
Array
(
[0] => Array
(
[size] => 11178232
[offset] => 33760
)
[1] => Array
(
[size] => 1210040
[offset] => 16801024
)
[2] => Array
(
[size] => 15542104
[offset] => 18012280
)
)
It's curious, but seems that with a manual serialization, APC splits the first and last pieces of data in a larger blocks, doing a better disposition of content.
Doesn't seem to be something trivial because I ran this test a couple times and I got similar results everytime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With