diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2015-10-16 17:49:20 -0400 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2015-10-19 14:21:51 +1100 |
commit | 8ca2a5d6d84d93b456a8dfa622707ae9222a388a (patch) | |
tree | cbc3670fc63412844b5ba5561b98773eb0ccd728 /mg.c | |
parent | 03a8022922436d6126806f2021d599237739ff83 (diff) | |
download | perl-8ca2a5d6d84d93b456a8dfa622707ae9222a388a.tar.gz |
reimplement $^WIN32_SLOPPY_STAT as a magic var
The original implementation in commit cba61fe146 was sloppy. It is named
like a special var, it is listed as a special var, but it was a regular GV.
Since nobody knows this var exists, and full stat is the default (which I
disagree with see below). There will be alot more PP and C/XS perl stat()
calls (atleast a couple to dozens or low 100s for short lived perl
processes) than reads/writes to this global scalar (rounded to 0 R/Ws)
in a Win32 perl process. So avoid the 1 usually failing GV package (hash)
lookup for each PP/XS/PL C stat by using magic vars and a C bool. This is
a perf increase. Use sv_true instead of SvTRUE_NN because this code is
extremely rare to execute and the macro has large machine code.
I disagree with the default being full stat with since this increases the
number of kernel IO calls and ASCII->UTF16 conversions, and there was
perf criticism in the original thread that implemented this
this http://www.nntp.perl.org/group/perl.perl5.porters/2006/02/msg109917.html
but why full stat is default is for another ticket. This patch lessens the
overhead of full stat until something else is decided.
Change the initial value of the sloppystat setting for miniperl to be true
instead of doing it in buildcustomize.pl in PP. Revert part of
commit 8ce7a7e8b0 "speed up miniperl require on Win32" to acomplish this.
Unlike Unix perl, no object files are shared between mini and full perl,
so changing the default is fine on Win32 Perl. If minitest/miniperl really
need hard link testing/support, they can explictly turn off sloppy stat
and enable full stat with the special var. Changing the stat default from
C for miniperl avoids creating the special GV on each miniperl process
start as it previously was with the buildcustomize.pl way.
Changing stat setting in C and not PP also saves a couple IO calls in
win32_stat when opening the first .pl if it isn't -e, and
opening buildcustomize.pl in all permutations. The PP code in S_parse_body
contains a -f. See ticket for this patch for details.
Only CPAN use of this special var is
File-Stat-Moose-0.06/lib/File/Stat/Moose.pm#L208 according to cpangrep.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -1041,6 +1041,11 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) *PL_compiling.cop_warnings); } } +#ifdef WIN32 + else if (strEQ(remaining, "IN32_SLOPPY_STAT")) { + sv_setiv(sv, w32_sloppystat); + } +#endif break; case '+': if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { @@ -2802,6 +2807,11 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) } } } +#ifdef WIN32 + else if (strEQ(mg->mg_ptr+1, "IN32_SLOPPY_STAT")) { + w32_sloppystat = (bool)sv_true(sv); + } +#endif break; case '.': if (PL_localizing) { |