Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl5.18-5.24: Slow pos function in taint mode with \G and unicode #15813

Closed
p5pRT opened this issue Jan 18, 2017 · 6 comments
Closed

perl5.18-5.24: Slow pos function in taint mode with \G and unicode #15813

p5pRT opened this issue Jan 18, 2017 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 18, 2017

Migrated from rt.perl.org#130584 (status was 'resolved')

Searchable as RT130584$

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2017

From @hknutzen

This is a follow-up on bug #50250.
It had been fixed for perl5.10.1, but is back since perl5.18 if called
in taint mode.

Create test data with this command line​:
perl -e 'print "x"x100000'>large

perlbrew use perl-5.16.3
time perl -T -C -e '$_=<>;while(1){/\G./g;pos||last;}' large
perlbrew use perl-5.18.4
time perl -T -C -e '$_=<>;while(1){/\G./g;pos||last;}' large

perl-5.16.3​: 0.6 seconds
perl-5.18.4​: 22 seconds

The slowdown still occurs with perl-5.24.1

@p5pRT
Copy link
Author

p5pRT commented Jan 21, 2017

From @iabyn

On Wed, Jan 18, 2017 at 12​:50​:57PM -0800, Heinz Knutzen wrote​:

# New Ticket Created by Heinz Knutzen
# Please include the string​: [perl #130584]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=130584 >

This is a follow-up on bug #50250.
It had been fixed for perl5.10.1, but is back since perl5.18 if called
in taint mode.

Create test data with this command line​:
perl -e 'print "x"x100000'>large

perlbrew use perl-5.16.3
time perl -T -C -e '$_=<>;while(1){/\G./g;pos||last;}' large
perlbrew use perl-5.18.4
time perl -T -C -e '$_=<>;while(1){/\G./g;pos||last;}' large

perl-5.16.3​: 0.6 seconds
perl-5.18.4​: 22 seconds

The slowdown still occurs with perl-5.24.1

Now fixed in blead with the following​:

commit b949b68
Author​: David Mitchell <davem@​iabyn.com>
AuthorDate​: Sat Jan 21 15​:47​:43 2017 +0000
Commit​: David Mitchell <davem@​iabyn.com>
CommitDate​: Sat Jan 21 15​:47​:43 2017 +0000

  avoid disabling utf8 pos cache on tainted strings
 
  RT #130584
 
  When pos() or similar is used on a utf8 string, perl attaches magic
  to it that caches a couple of byte<->char offset conversions. This can
  avoid quadratic behaviour when continually scanning a big chunk of a long
  string to convert a byte offset to a char offset when pos() is called.
 
  v5.17.3-203-g7d1328b added code to invalidate this cache when get magic is
  called on an SV, since the get magic may change the value of the SV.
 
  However, under -T, taint magic gets added to a tainted string, which
  includes a get method which doesn't actually change the SV's value.
  So make a special exception to get-magic-cache-invalidation if the only
  get magic on the string is taint.
 
  This stops code like the following going quadratic under -T​:
 
  $_ = "... long tainted utf8 string ...";
  while ( /..../g) {
  my $p = pos(); # calculating pos() goes quadratic
  }

M mg.c
M t/perf/taint.t

--
Music lesson​: a symbiotic relationship whereby a pupil's embellishments
concerning the amount of practice performed since the last lesson are
rewarded with embellishments from the teacher concerning the pupil's
progress over the corresponding period.

@p5pRT
Copy link
Author

p5pRT commented Jan 21, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 23, 2017

@iabyn - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant