Re: New optimization idea; was: No runtime fetching of built-in global constants
| From: | Arnaud Le Blanc | Date: | Sun, 27 Jul 2008 14:22:50 +0000 |
| Subject: | Re: New optimization idea; was: No runtime fetching of built-in global constants | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-39380@lists.php.net to get a copy of this message | ||
Hi,
On Sunday 27 July 2008 15:35:11 Matt Wilmas wrote:
>
> Sorry, but now I'm the one who's confused here, since I have no idea what
> I'm supposed to look into exactly. :-/ I know about shebang lines, and I
> know there's a check in the scanner now to skip over it (must have been
> somewhere else with flex...). PHP itself doesn't "use" the shebang, does
> it? I don't have much knowledge of *nix system stuff, but I thought the
> shebang is for the OS to use when asked to run an executable script...
The shebang line is used by the operating system to know which interpreter to
use to execute the file. In most cases this does not cause any problem to the
interpretor as lines starting with # are comments in many languages, but in
PHP it's not a comment as long as it's not enclosed with <?php ?>, so PHP
must check if there is a shebang line and skip it.
>
> So I don't understand what could be changed in the scanner to save the open
> syscall -- since if the scanner is called, the file has already been opened,
> right? Again, sorry, but I'll need more explanation. :-)
Actually the CGI SAPI opens the file, seeks after the shebang line, and then
passes the opened file descriptor to the scanner.
I see two solutions for that:
Make the scanner completely bypass the shebang line if
cgi.check_shebang_line==1
Or let the executor decide wether to output the shebang or not by enclosing it
in a "SHEBANG" opcode for example.
Regards,
Arnaud