Open p5pRT opened 15 years ago
This is on Win32...
I noticed a slowdown in performance of C\< /pat/i > case insensitive regular expressions when used in fork code. Interestingly if the regexp was compiled within the fork'd code it ran at the expected rate. NB. the same results were obtained in either case - it was just the time taken that was different.
The following testcase shows an interesting difference in behaviour which i suspect is the culprit of the difference in time taken:
# %\<
use re qw(Debug All);
my $pid = fork; defined $pid or die;
if ($pid == 0) { $_ = "abcNEEDLE123\n";
print STDERR "\n## 1 ##\n\n"; /needle/i;
print STDERR "\n## 2 ##\n\n"; eval q{ /needle/i };
exit; }
while (wait() != -1) {}
$_ = "abcNEEDLE123\n";
print STDERR "\n## 3 ##\n\n"; /needle/i;
# >%
And here is the output:
# %\<
Compiling REx "needle"
Final program:
1: EXACTF \
## 1 ##
Matching REx "needle" against "abcNEEDLE123%n"
0 \<> \
## 2 ##
Compiling REx "needle"
Final program:
1: EXACTF \
## 3 ##
Matching REx "needle" against "abcNEEDLE123%n"
Matching stclass EXACTF \
# >%
So it appears the /regexp/i is 'run' differently within the child thread if it was compiled in the main thread.
Additionally\, running the testcase on my Strawberry 5.10 perl also gave some assert warnings:
Assertion ((svtype)((_svi)->sv_flags & 0xff)) >= SVt_PV failed: file "re_exec.c"\, line 2561
Is this a bug\, or simply a necesary change in the code path taken to get /regexp/i to work in a threaded environment?
Thanks for taking a look.
Cheers\, alex.
On Tue\, Feb 17\, 2009 at 10:35:44AM -0800\, alex.davies@talktalk.net (via RT) wrote:
I noticed a slowdown in performance of C\< /pat/i > case insensitive regular expressions when used in fork code.
I can confirm this is reproducible in bleed using Linux and threads:
use threads; sub child { $_ = "abcNEEDLE123\n";
use re qw(Debug All); print STDERR "\n## 1 ##\n\n"; /needle/i;
print STDERR "\n## 2 ##\n\n"; eval q{ /needle/i }; } threads->new(\&child)->join;
which outputs:
Compiling REx "needle"
Final program:
1: EXACTF \
## 1 ##
Matching REx "needle" against "abcNEEDLE123%n"
0 \<> \
## 2 ##
Compiling REx "needle"
Final program:
1: EXACTF \
I see the same behaviour under 5.8.8\, so this isn't a 5.10.0 regression. (So I'll let someone else worry about fixing it!)
-- "But Sidley Park is already a picture\, and a most amiable picture too. The slopes are green and gentle. The trees are companionably grouped at intervals that show them to advantage. The rill is a serpentine ribbon unwound from the lake peaceably contained by meadows on which the right amount of sheep are tastefully arranged." -- Lady Croom\, "Arcadia"
The RT System itself - Status changed from 'new' to 'open'
This persists in 5.35.10. I suspect it is one case doesn't use boyers-moore
Migrated from rt.perl.org#63284 (status was 'open')
Searchable as RT63284$