# realpath() caching

- Thread: https://externals.io/message/11484
- Original archive: https://news-web.php.net/php.internals/11484
- Started by Andi Gutmans on 2004-07-22T21:30:00+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

---

## #11484 — Andi Gutmans — 2004-07-22T21:30:00+00:00

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

Hi guys,

Before 5.0.0 we promised we'll get something together for solving the 
performance problems caused by Zend always `realpath()`'ing include files (in 
expand_filepath()).
Attached is a proposed implementation of such a cache. We tried to make it 
as simple as possible and tests shows that it solves the performance problems.
A few facts about it:
a) Expiration and Cache size are still hardcoded and not INI options in 
tsrm_virtual_cwd.h. Didn't want to go through the trouble of doing it 
because we agree on the implementation.
b) tsrm_hash.* is a full blown hash and not a stripped down hash which is 
all that's needed for this. It'll be stripped down.
c) In my opinion and tests, having a memory limit on the cache works great 
because it makes sure the cache doesn't go crazy and even in like 16K of 
memory you can usually cache all of the `realpath()`'s.
d) Current expiration for an entry is 2 minutes which is also plenty.
e) I wouldn't make it much more complicated or "smarter" than this because 
it'll just add lots of code and will probably not perform much better.

Comments welcome. Let's get this baby into PHP 5.1!

Andi

---

## #11485 — Andrei Zmievski — 2004-07-22T22:02:34+00:00

URL: https://externals.io/message/11484#11485 · In reply to: #11484

Attachment didn't come through.


> Hi guys,
> 
> Before 5.0.0 we promised we'll get something together for solving the 
> performance problems caused by Zend always `realpath()`'ing include files (in 
> expand_filepath()).
> Attached is a proposed implementation of such a cache. We tried to make it 
> as simple as possible and tests shows that it solves the performance 
> problems.
> A few facts about it:
> a) Expiration and Cache size are still hardcoded and not INI options in 
> tsrm_virtual_cwd.h. Didn't want to go through the trouble of doing it 
> because we agree on the implementation.
> b) tsrm_hash.* is a full blown hash and not a stripped down hash which is 
> all that's needed for this. It'll be stripped down.
> c) In my opinion and tests, having a memory limit on the cache works great 
> because it makes sure the cache doesn't go crazy and even in like 16K of 
> memory you can usually cache all of the `realpath()`'s.
> d) Current expiration for an entry is 2 minutes which is also plenty.
> e) I wouldn't make it much more complicated or "smarter" than this because 
> it'll just add lots of code and will probably not perform much better.
> 
> Comments welcome. Let's get this baby into PHP 5.1!
> 
> Andi

> -- 
> 
> 


- Andrei
