# open_basedir performance issue, realpathcache vs. statcache

- Thread: https://externals.io/message/43041
- Original archive: https://news-web.php.net/php.internals/43041
- Started by Roland Mieslinger on 2009-02-14T22:13:29+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43041 — Roland Mieslinger — 2009-02-14T22:13:29+00:00

URL: https://externals.io/message/43041#43041

Hello,

we're managing a shared hosting environment with about 600 virtual
servers. All content for the websites is stored on a NFS share.

We're suffering from a huge amount of lstat calls, and identified 
open_basedir as the reason for that. strace shows that each call
needs 40µs in average, this is due to NFS.

A lot of questions arises from that, but some answers are still missing.
Maybe I can get them here.

Did open_basedir rely on realpathcache? I haven't found a definitive
answer to that. We have changed realpath cache size, without any impact.
So I assume the answer is no.

>From what I understand realpathcache is different from statcache. So
using clearstatcache should not flush the realpathcache. Am I correct?

Thanks for you help

Roland

---

## #43042 — Rasmus Lerdorf — 2009-02-14T22:23:27+00:00

URL: https://externals.io/message/43041#43042 · In reply to: #43041

Roland Mieslinger wrote:
> Hello,
> 
> we're managing a shared hosting environment with about 600 virtual
> servers. All content for the websites is stored on a NFS share.
> 
> We're suffering from a huge amount of lstat calls, and identified 
> open_basedir as the reason for that. strace shows that each call
> needs 40µs in average, this is due to NFS.
> 
> A lot of questions arises from that, but some answers are still missing.
> Maybe I can get them here.
> 
> Did open_basedir rely on realpathcache? I haven't found a definitive
> answer to that. We have changed realpath cache size, without any impact.
> So I assume the answer is no.
> 
> > […]
> using clearstatcache should not flush the realpathcache. Am I correct?

clearstatcache does flush the realpathcache in PHP 5.2.  This has been
turned off by default in 5.3 and is now an option on the
 `clearstatcache()` call.

The realpathcache in 5.3 is also more efficient now in that it will
cache partial paths.  In 5.2 we relied on the system's `realpath()` call
and only cached complete results from it.  That also meant that there is
no negative caching going on, so if you have a bunch of include_path
misses, you are going to die a slow stat death in 5.2.

In 5.2 make sure your main include_path dir is the first path in the
order there.  Put "." at the end and always use include './foo.php' when
you include something relative to the script's directory.  That should
alleviate a lot of the stat issues.

-Rasmus
