# [PATCH] suppressing realpath() with APC + tiny patches

- Thread: https://externals.io/message/9697
- Original archive: https://news-web.php.net/php.internals/9697
- Started by BUSTARRET on 2004-05-07T08:45:11+00:00
- Messages: 3
- 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

---

## #9697 — BUSTARRET — 2004-05-07T08:45:11+00:00

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

I know the location is not the best one (IMHO, the PEAR default is not much metter). You can't always have the fastest setup, because there are many other factors to consider (security, ease of management, number of servers/apps to handle, ...).

My point was to evaluate the impact of the patch. Wherever you put your files, it has a dramatic impact on performance, and I wish it (or any similar patch) was part of the standard PHP distribution.

Let's get rid of this useless (when using a cache) realpath call, without having to migrate to PHP5 !

JFB

> -----Message d'origine-----
> De : Sterling Hughes [mailto:sterling@php.net]
> Envoyé : vendredi 7 mai 2004 00:15
> À : BUSTARRET, Jean-Francois
> Cc : internals@lists.php.net
> Objet : Re: [PHP-DEV] [PATCH] suppressing `realpath()` with APC + tiny
> patches
>

>

> the first thing you would optimize is your code location -

> not your php

> installation...
>

>

> 
>

> > […]

> 4.2.3/APC 2.0.3.
> > […]

> > […]

> > […]

> > […]

> > […]

> auteur, et ne

> > […]

> > […]

> your system.

> > […]

> > […]
>

>


-------------------------------------
Le present message (y compris tous les elements attaches) est confidentiel et est destine a ses seuls destinataires. Si vous
l'avez recu par erreur, merci de l'indiquer a son expediteur par retour et de proceder a sa destruction dans vos systemes.

Toute utilisation ou diffusion non autorisee de son contenu, en totalite ou en partie, est strictement interdite. Les idees et

opinions presentees dans ce message sont celles de son auteur, et ne representent pas necessairement celles de TF1 (et/ou des

entites membres du Groupe TF1).

This message (including any attachments) is confidential and may be privileged. If you have received it by mistake please notify

the sender by return email and delete this message from your system. Any unauthorised use or dissemination of this message in

whole or in part is strictly prohibited. Any views or opinions presented are solely those of its author and do not necessarily

represent those of TF1 (and/or its group companies).

---

## #9705 — Rasmus Lerdorf — 2004-05-07T13:41:58+00:00

URL: https://externals.io/message/9697#9705 · In reply to: #9697

> Let's get rid of this useless (when using a cache) realpath call, without having to migrate to PHP5 !

Well, the realpath call's usefulness doesn't have anything to do with the
cache.  It is there to provide a canonicalized absolute pathname to be
stored in the included_files list and on every include another realpath is
done to check against this list.  This means that if the same file is
included via different paths, the include_once/require_once will still
catch that fact.

Now, I do agree with you that the cost for this convenience is way too
high which is why I turn this off for my use and tell people they get what
they deserve if they include the same file via different paths.  Of
course, turning this off also messes up any open_basedir checks as it
becomes trivial to work around an open_basedir restriction with a symlink
or some creative path walking.

 I did try your patch and it crashed my build.  Granted, my tree is quite
hacked up and doesn't ever call realpath, but still.  Haven't had time to
track down exactly why it caused problems.

-Rasmus

---

## #9788 — Masaki fujimoto — 2004-05-10T09:44:43+00:00

URL: https://externals.io/message/9697#9788 · In reply to: #9705

Hello,

All of your point is acceptable for me, too. Of cource I do not 
think APC has something to do with realpath calls, and as I wrote in 
another mail, APC is just a way to make skipping `realpath()` calls 
more easy (to be exact, it's the way to suppress `realpath()` only once 
for each script through all the process. So this patch can 
identify the same script in different path).

I tried some other ways to skip realpath (like realpath caching), and 
then concluded that my previous patch was the simplest, smallest, and 
most effective one.

Anyway, I think Andi's realpath cache which mentioned in another mail 
will be the great help of most of people, and I'm happy if it'll be 
committed in php-src (of course I'm happier if I can commit my 
patch, too:), but if you want to enhance your PHP more (especially in 
PHP 4, which will not have realpath cache), and if you could 
arbitrarily build your PHP, I believe my patch should be the great 
help, too.

Finally, an attacehd patch will prevent your crash, but if you already 
turned all the realpath calls off, my patch will not affect any 
performance...

Masaki Fujimoto

The Message From Rasmus Lerdorf:
> 
> > […]
> 
> Well, the realpath call's usefulness doesn't have anything to do with the
> cache.  It is there to provide a canonicalized absolute pathname to be
> stored in the included_files list and on every include another realpath is
> done to check against this list.  This means that if the same file is
> included via different paths, the include_once/require_once will still
> catch that fact.
> 
> Now, I do agree with you that the cost for this convenience is way too
> high which is why I turn this off for my use and tell people they get what
> they deserve if they include the same file via different paths.  Of
> course, turning this off also messes up any open_basedir checks as it
> becomes trivial to work around an open_basedir restriction with a symlink
> or some creative path walking.
> 
>  I did try your patch and it crashed my build.  Granted, my tree is quite
> hacked up and doesn't ever call realpath, but still.  Haven't had time to
> track down exactly why it caused problems.
> 
> -Rasmus
