php.net |  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
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:3 (60.0%)
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
Description:
------------
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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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());

325
6
57
1692

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

https://github.com/php/php-src/commit/782b84c6d550ac6e695b54070bb0b409cac29f58
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed May 22 19:01:32 2019 UTC