Req #70507 [Com]: Combination of is_file() + include (e.g. "include_if_exists")
| From: | andreas at dqxtech dot net | Date: | Tue, 15 Sep 2015 22:10:02 +0000 |
| Subject: | Req #70507 [Com]: Combination of is_file() + include (e.g. "include_if_exists") | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196027@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70507&edit=1
ID: 70507
Comment by: andreas at dqxtech dot net
Reported by: andreas at dqxtech dot net
Summary: Combination of is_file() + include (e.g.
"include_if_exists")
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 7.0.0RC2
Block user comment: N
Private report: N
New Comment:
> If you guys agree this is the case then fine..
At least requinix above says that not all functions are using the file exists cache.
> I recall measuring a slight difference there. Not a big worry, but relevant enough for the
> "fastest classloader in town" game..
And I imagine filesystem performance can be different depending on the environment.
Previous Comments:
------------------------------------------------------------------------
[2015-09-15 22:08:15] andreas at dqxtech dot net
> I think opcache is already caching file existence checks, so doing file_exists (or is_file)
> should be very cheap once the file is in cache.
If you guys agree this is the case then fine..
I recall measuring a slight difference there. Not a big worry, but relevant enough for the
"fastest classloader in town" game..
> Can't you just do @include?
Someone will tell me I shouldn't. I am sure of that :)
------------------------------------------------------------------------
[2015-09-15 21:39:13] stas@php.net
Can't you just do @include?
I think opcache is already caching file existence checks, so doing file_exists (or is_file) should
be very cheap once the file is in cache.
------------------------------------------------------------------------
[2015-09-15 20:18:38] andreas at dqxtech dot net
Does this cache also cover file permissions?
------------------------------------------------------------------------
[2015-09-15 20:16:55] andreas at dqxtech dot net
> If you're concerned about how include/etc. do their own file lookups then wouldn't it
> be better to fix that specifically? PHP has a file stat cache already where the result of the first
> lookup is reused throughout execution (unless the cache gets cleared). I did some quick strace tests
> and it doesn't look like the functions are using it...
Sure, sounds a good idea!
I'm afraid I'm not going to be of much help here though. Never touched the internals
stuff.
------------------------------------------------------------------------
[2015-09-15 20:08:11] requinix@php.net
For consistency there would have to be two functions: include_if_exists and include_once_if_exists.
And files executed through those would not be able to use "return" to return values to the
caller; having the functions an object would be a jarring departure from how the others work.
If you're concerned about how include/etc. do their own file lookups then wouldn't it be
better to fix that specifically? PHP has a file stat cache already where the result of the first
lookup is reused throughout execution (unless the cache gets cleared). I did some quick strace tests
and it doesn't look like the functions are using it...
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=70507
--
Edit this bug report at https://bugs.php.net/bug.php?id=70507&edit=1