|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73888 realpath_cache should be SHM
Submitted: 2017-01-07 18:40 UTC Modified: 2017-01-11 10:48 UTC
Avg. Score:4.6 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:4 (66.7%)
From: spam2 at rhsoft dot net Assigned:
Status: Open Package: Performance problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-01-07 18:40 UTC] spam2 at rhsoft dot net
in theory "realpath_cache" is a nice concept, but when you do repeatly print_r(realpath_cache_get()); you see it's very randomly depending on the forker instance you hit and so it's not really effective - on server with high load and so many hundret processes each maintains it's own cache and the hit rate because ttl is reached drops heavily

besides it's not a effective as it should be there are more disadvantages:

* you waste memory realpath_cache_size muliplied with process count
* clearstatcache() called by applications after file-changes
  is more or less worthless because only the worker process
  issuing the command is affected while others still use cached results

so this should work like "apcu" with a SHM segment sahred by all workers or since PHP now has 'opcache' shared between workers and doing all sorts of optimizations (include-hack, interned string buffers..) maybe the storage for realpath_cache could even go to 'opcache' at all


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-07 18:57 UTC] spam2 at rhsoft dot net
maybe these numbers a view minutes after reload http makes the problem clear:

echo count(realpath_cache_get());


so we have one forker with a effective cache of 1692 records while another one a few seconds before only had 6 cache entries and so don't benefit from anything
 [2017-01-11 10:48 UTC] spam2 at rhsoft dot net
and as long as every httpd process maintains it's authistic realpath_cache commits like below are harmful because wit 500 forkers under load you end in 900 MB wasted memory instead 4 MB
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 23:01:28 2024 UTC