php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64624 Use a SLAB-style memory allocator to avoid fragmentation
Submitted: 2013-04-10 16:25 UTC Modified: 2013-04-11 04:17 UTC
From: martin dot langhoff at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.3.23 OS: Linux / RHEL6.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: martin dot langhoff at gmail dot com
New email:
PHP Version: OS:

 

 [2013-04-10 16:25 UTC] martin dot langhoff at gmail dot com
Description:
------------
Memory fragmentation in APC is a significant problem. Currently apc.php contains 
code to show fragmentation, and a recommendation is to deal with it by bouncing 
apache or calling apc_clear_cache() regularly.

These workarounds should not be needed with a simple slab-style memory allocator.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-10 16:58 UTC] rasmus@php.net
-Status: Open +Status: Wont fix
 [2013-04-10 16:58 UTC] rasmus@php.net
There won't be any major changes like that to APC. Development has moved to 
opcache. See http://pecl.php.net/package/ZendOpcache
 [2013-04-10 17:48 UTC] martin dot langhoff at gmail dot com
Hi Rasmus - thanks for this info.

One more question (because APC will continue to see usage in PHP <5.5).

In order to have a good/better workaround for the current APC code, I would like 
to have good fragmentation stats. You wrote in https://bugs.php.net/bug.php?
id=58510 that "The fragmentation calculation is a bit artificial and may need to 
be updated for 3.1.2 actually."

In SVN, the apc.php code has not seen changes to the fragmentation calc, so I 
guess that never happened. 

To be more explicit, I am working on the following simplified (pseudo)code:

function my_request_shutdown() {
    if (rand(1, 1000) === 1) { #
        fragmentation = code lifted from apc.php
        if (fragmentation > 80) {
            apc_clear_cache();
        }
    }
}
register_shutdown_function('my_request_shutdown');

If the fragmentation code in apc.php is busted, I'm interested in hints to improve 
it. 

Background -- this is for the rather popular Moodle LMS.

Thanks again ~
 [2013-04-10 22:00 UTC] rasmus@php.net
Are you actually seeing fragmentation issues? Forget what apc.php tells you, are 
you actually seeing performance degradation due to fragmentation? Honestly I have 
never been able to measure any degradation myself even when apc.php tells me the 
cache is highly fragmented.
 [2013-04-10 22:35 UTC] martin dot langhoff at gmail dot com
Yes, we have a busy Moodle installation showing a very significant slowdown in PHP 
execution. This is in a VM so the workload is well-defined: Moodle. All stats were 
normal, except the apc.php script indicating 100% fragmentation.

Apache graceful restart cured both the fragmentation report and the PHP execution 
slowdown.

Correlation is not causation, but it sure is a hint!
 [2013-04-11 04:17 UTC] rasmus@php.net
Increasing your segment size should help quite a bit then along with a graceful 
every couple of days. And note that opcache works quite well with PHP 5.4 as 
well.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 17:01:35 2024 UTC