apcu icon indicating copy to clipboard operation
apcu copied to clipboard

Prevent unnecessarily frequent default expunge operations

Open madmajestro opened this issue 5 months ago • 5 comments

A full cache wipe is now performed if too little SHM has been freed by removing expired entries during the default expunge operation. This is intended to prevent unnecessarily frequent calls of the default expunge operation, which should reduce cpu load in some cases. The new configuration setting apc.expunge_threshold defaults to 5 (0.5%) and specifies the thousandth of SHM that must be available after expired entries have been removed during the default expunge operation. Since apc.expunge_threshold replaces apc.smart, apc.smart has been removed.

madmajestro avatar Aug 15 '25 13:08 madmajestro

This is my suggestion for reducing high CPU usage caused by frequently executed default expunge operations.

In my tests, this seemed effective. The number of cleanups and defragmentations decreased, while the number of expunges remained constant.

madmajestro avatar Aug 15 '25 13:08 madmajestro

Even if it works well with 1 %, it would also be reasonable to use thousendth instead of percent. If the general concept is ok, i could do some additional testing + tuning with values lower than 1 %.

madmajestro avatar Aug 16 '25 08:08 madmajestro

@nikic Friendly ping.

We should take care of this PR first, as it affects the test results of #589. If this is merged, I'd like to do some more testing / fine-tuning with #589 before it is merged.

madmajestro avatar Aug 21 '25 17:08 madmajestro

Fixed. Yes, that's a good idea. It's easier to understand and more flexible.

madmajestro avatar Sep 24 '25 20:09 madmajestro

I wonder whether it would make sense to create a release from the current master branch before merging this.

nikic avatar Dec 06 '25 11:12 nikic

I wonder whether it would make sense to create a release from the current master branch before merging this.

I agree. It probably wouldn't hurt, but this is the safer approach.

But please take a look at #606 before creating a release.

madmajestro avatar Dec 07 '25 00:12 madmajestro

@nikic I just saw that you released version 5.1.28 on pecl, but the release isn't available on GitHub yet…

madmajestro avatar Dec 08 '25 08:12 madmajestro

@nikic I just saw that you released version 5.1.28 on pecl, but the release isn't available on GitHub yet…

Oops, fixed.

nikic avatar Dec 08 '25 08:12 nikic