krakjoe / apcu

APCu - APC User Cache
Other
957 stars 193 forks source link

Reduce memory per shm string by 8 bytes #465

Open TysonAndre opened 1 year ago

TysonAndre commented 1 year ago

Related to #323

This slightly helps performance of apc.serializer=default when there are lots of small strings to unpersist. (and reduces size of serialized data (and cache entry keys) by 8 bytes with other serializers (16 bytes per entry))

With APCu's current design and eviction always being a possibility, strings must always be copied. (zval flags could be used to check the type if that stopped being the case)

For example, fetching a large array mapping small strings to small strings (CPU running at 2.5GHz):

Before: bench_apcu_fetch_large_config: numValues=     65536
repetitions=       256 elapsed=3.010 shared memory=   9381144
After: bench_apcu_fetch_large_config: numValues=     65536
repetitions=       256 elapsed=2.980 shared memory=   8332560
Benchmark source code (click to expand) ```php