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.
case '\027': /* $^WARNING_BITS */
if (strEQ(name2, "ARNING_BITS"))
goto magicalize;
+#ifdef WIN32
+ else if (strEQ(name2, "IN32_SLOPPY_STAT"))
+ goto magicalize;
+#endif
break;
case '1':
case '2':
*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))) {
}
}
}
+#ifdef WIN32
+ else if (strEQ(mg->mg_ptr+1, "IN32_SLOPPY_STAT")) {
+ w32_sloppystat = (bool)sv_true(sv);
+ }
+#endif
break;
case '.':
if (PL_localizing) {
editing <.bashrc> will not change the enviromental variable in other existing,
running, processes.
+=item *
+
+One glob fetch was removed for each C<-X> or C<stat> call whether done from
+Perl code or internally from Perl's C code. The glob being looked up was
+C<${^WIN32_SLOPPY_STAT}> which is a special variable. This makes C<-X> and
+C<stat> slightly faster.
+
+=item *
+
+During Miniperl's process startup, during the build process, 4 to 8 IO calls
+related to the process starting C<.pl> and the C<buildcustomize.pl> file were
+removed from the code opening and executing the first 1 or 2 C<.pl> files.
+
=back
=back
int nlink = 1;
BOOL expect_dir = FALSE;
- GV *gv_sloppy = gv_fetchpvs("\027IN32_SLOPPY_STAT",
- GV_NOTQUAL, SVt_PV);
- BOOL sloppy = gv_sloppy && SvTRUE(GvSV(gv_sloppy));
-
if (l > 1) {
switch(path[l - 1]) {
/* FindFirstFile() and stat() are buggy with a trailing
path = PerlDir_mapA(path);
l = strlen(path);
- if (!sloppy) {
+ if (!w32_sloppystat) {
/* We must open & close the file once; otherwise file attribute changes */
/* might not yet have propagated to "other" hard links of the same file. */
/* This also gives us an opportunity to determine the number of links. */
w32_timerid = 0;
w32_message_hwnd = CAST_HWND__(INVALID_HANDLE_VALUE);
w32_poll_count = 0;
+#ifdef PERL_IS_MINIPERL
+ w32_sloppystat = TRUE;
+#else
+ w32_sloppystat = FALSE;
+#endif
for (i=0; i < SIG_SIZE; i++) {
w32_sighandler[i] = SIG_DFL;
}
dst->timerid = 0;
dst->message_hwnd = CAST_HWND__(INVALID_HANDLE_VALUE);
dst->poll_count = 0;
+ dst->sloppystat = src->sloppystat;
Copy(src->sigtable,dst->sigtable,SIG_SIZE,Sighandler_t);
}
# endif /* USE_ITHREADS */
UINT timerid;
unsigned poll_count;
Sighandler_t sigtable[SIG_SIZE];
+ bool sloppystat;
};
#define WIN32_POLL_INTERVAL 32768
#define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype)
#define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow)
#define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow)
+#define w32_sloppystat (PL_sys_intern.sloppystat)
#ifdef USE_ITHREADS
void win32_wait_for_children(pTHX);
# We are miniperl, building extensions
# Replace the first entry of \@INC ("lib") with the list of
# directories we need.
-${\($^O eq 'MSWin32' ? '${^WIN32_SLOPPY_STAT} = 1;':'')}
splice(\@INC, 0, 1, $inc);
\$^O = '$osname';
__END__