|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58111 apc_clear_cache('user') takes long time with lots of cache entries
Submitted: 2008-03-20 07:13 UTC Modified: 2008-06-26 08:23 UTC
From: lgr888999 at gmail dot com Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.2.1 OS: Linux 2.6.9-42.0.2.ELsmp
Private report: No CVE-ID: None
 [2008-03-20 07:13 UTC] lgr888999 at gmail dot com
Notice: Using php 5.2.5 which is not available in the list above

Ive made a warmup script to 1) clear the cache  2) fill the cache

While filling the cache with 70 000 entries takes only 1.5 second  running apc_clear_cache('user') afterwards takes 50-200 seconds.  

I took a look in apc.c to see how the clearing works and it seems like it deletes one entry at the time, is that correct?

Would be cool if there could be some purge option to just swap out everything, which I thought apc_clear_cache did.

Expected result:
Cleanup: 3.6001205444336E-5s 
Warmup: 1.6538591384888s 

Actual result:
Cleanup: 51.65371680259s 
Warmup: 1.6538591384888s 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-23 21:14 UTC]
Just looking at the code briefly, I don't see any obvious performance changes I can make.  We must walk all the entries to make sure that no other process is using them (and if they are we have to put it on a garbage collection list for later).  

If you have this many entries, it may be preferable to either come up  with another scheme to dirty entries on the fly, or to just restart your server. 

I'll leave this as a feature request in case someone can come up with some other method in the future.
 [2008-06-05 15:20 UTC] peter dot koerner at tmp dot de
If apc_clear_cache('user') takes longer than phps max_execution_time the script calling apc_clear_cache will be terminated by php before the clearing-operation is finished. this seems to leave some handles or sth. that will prevent apache from closing it's processes.

This was confirmed on a 32bit 2.6.9 CentOS with PHP 5.1.6, Apache 2.0.59 using php-pecl-apc.i386 version  3.0.12-1.el4.centos.

It took our server down for one night running about 2000 apache processes that waitet for termination. restarting the server helped for one day but than that effect came back. adding set_time_limit(0) just before apc_clear_cache solved the problem.
 [2008-06-26 08:23 UTC] gopalv82 at yahoo dot com
Pretty much identical to the

The cache clear has to do it item by item, but the memory cleanup operations have been re-designed to be much faster. Much, much faster.

Please checkout CVS HEAD & test it out
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 03:03:36 2021 UTC