In perl.git, the branch smoke-me/jkeenan/bulk88/126377-remove-extra-stat-call has been created
<http://perl5.git.perl.org/perl.git/commitdiff/38c059e1fcc35934bb8545a6db174f512fc8df6d?hp=0000000000000000000000000000000000000000> at 38c059e1fcc35934bb8545a6db174f512fc8df6d (commit) - Log ----------------------------------------------------------------- commit 38c059e1fcc35934bb8545a6db174f512fc8df6d Author: Daniel Dragan <[email protected]> Date: Fri Oct 16 17:40:38 2015 -0400 remove extra stat() call from .pm opening+remove extra safepath check Originally S_doopen_pm had 2 stat calls, one on the .pm path, and another on the .pmc, to get mtimes of both. Commit a91233bf4c "Load .pmc always, even if they are older than a matching .pm file." (see http://www.nntp.perl.org/group/perl.perl5.porters/2006/03/msg110639.html ) got rid of one of the stat calls but the other was left in place, possibly as an oversight. S_check_type_and_open itself does another stat call on unix to check for bad kinds of FS entries (reading a dir as a file), so assuming someone used .pmc files, a good .pmc would be stat, stat, open instead of the ideal, stat, open. Remove the extra stat from S_doopen_pm for efficiency. Since the timestamp compare was removed, the role of S_doopen_pm has been to verify an attempted path is acceptable to pass to the FS (no IO done), and generate a .pmc path (no IO done), the IO side of thing is in S_check_type_and_open, it shouldn't be in S_doopen_pm. On Win32, on a no .pmc build, an open is directly done on the attempted .pm path for efficiency, no stat is done normally (see commit d345f48775 "Win32: stat() only after a failed open() on a module"). Before this patch the .pmc attempted path got a stat which on Win32 is more than 1 IO call, compared to Win32 open which is 1 IO call. With this patch, the Win32 specific IO logic in S_check_type_and_open executes instead of a generic Win32 stat so there is just 1 failing IO call for file not found (typical case for .pmc) instead of multiple file not found IO calls. See ticket for details. When .pmc files are enabled (enabled is default), 2 checks for bad null char paths were done, once in S_doopen_pm, then again in lower level S_check_type_and_open. Do the check only once in the higher level call (S_doopen_pm) for efficiency, there is no way for string "c" which is catted on to contain a null. There was an existing comment refering to the problem of a low level check for null returning a message about a ".pmc" instead of a ".pm", so that is another reason to do it at a higher level. Note on no PMC builds, S_check_type_and_open replaces S_doopen_pm and still must do the check. ----------------------------------------------------------------------- -- Perl5 Master Repository
