Branch: refs/heads/blead
Home: https://github.com/Perl/perl5
Commit: f5f215ac9effa3f85e0ad647b61056207b841dd5
https://github.com/Perl/perl5/commit/f5f215ac9effa3f85e0ad647b61056207b841dd5
Author: Richard Leach <[email protected]>
Date: 2026-10-11 (Sun, 11 Oct 2026)
Changed paths:
M regexec.c
Log Message:
-----------
S_find_span_end: widen search to check 512 bits at a time
This commit adds two implementations:
* The faster relies on the compiler inlining _memcmp_
* The slower bytewise version should be portable
Testing with Compiler Explorer showed that:
* gcc & clang can inline memcmp and produce optimum code
* MSVC (not in clang-mode) does not inline memcmp at /O1 or /O2
Practical testing then revealed that:
* clang seems to pretty reliably inline memcmp
* gcc does not reliably inline when S_find_span_end is itself inlined
Consequently:
* clang will get the memcmp version
* gcc will get the memcmp version, plus __attribute((noinline))
* anything else will get the bytewise version
The following were used to test throughput of this function:
* string: `my $run_exact = ('x' x 2_000_000) . '.';`
* pattern: `$run_exact =~ /\Ax+/;`
The following results were seen:
Rate
blead (doesn't scale with -march) 6310/s
this commit, no -march, bytewise 16286/s
this commit, no -march, memcmp 22660/s
this commit, -march=x86-64-v2, bytewise 20379/s
this commit, -march=x86-64-v2, memcmp 29252/s
this commit, -march=x86-64-v3, bytewise 30772/s
this commit, -march=x86-64-v3, memcmp 47246/s
(No CPU to hand that supports -march=x86-64-v4.)
Commit: 201f8152c500bcab2066e75b214d7e0f4ded342d
https://github.com/Perl/perl5/commit/201f8152c500bcab2066e75b214d7e0f4ded342d
Author: Richard Leach <[email protected]>
Date: 2026-10-11 (Sun, 11 Oct 2026)
Changed paths:
M regexec.c
Log Message:
-----------
S_find_span_end_mask: widen search to check 512 bits at a time
The following were used to test throughput of this function:
* string: `my $run_anyofm = ('0' x 2_000_000) . '.';`
* pattern: `$run_anyofm =~ /\A[01]+/;`
The following results were seen:
Rate
blead (doesn't scale with -march) 9394/s
this commit, no -march 16140/s
this commit, -march=x86-64-v2 20003/s
this commit, -march=x86-64-v3 27659/s
(No CPU to hand that supports -march=x86-64-v4.)
Commit: cd259272c85e6878239ce1ff2fc8402a661b74fe
https://github.com/Perl/perl5/commit/cd259272c85e6878239ce1ff2fc8402a661b74fe
Author: Richard Leach <[email protected]>
Date: 2026-10-11 (Sun, 11 Oct 2026)
Changed paths:
M regexec.c
Log Message:
-----------
S_find_next_masked: widen search to check 512 bits at a time
The following were used to test throughput of this function:
* string: `my $run_nanyofm = ('B' x 2_000_000) . 'A';`
* pattern: `$run_nanyofm =~ /\A[^A]+/;`
The following results were seen:
Rate
blead (doesn't scale with -march) 4741/s
this commit, no -march 16365/s
this commit, -march=x86-64-v2 16290/s
this commit, -march=x86-64-v3 27534/s
(No CPU to hand that supports -march=x86-64-v4.)
Commit: 06de9aeef7494843350fdff25194f0dcc5945b5a
https://github.com/Perl/perl5/commit/06de9aeef7494843350fdff25194f0dcc5945b5a
Author: Richard Leach <[email protected]>
Date: 2026-10-11 (Sun, 11 Oct 2026)
Changed paths:
M regexec.c
Log Message:
-----------
S_find_next_masked: boost the word-at-a-time performance
The throughput of this loop was markedly lower than the word-at-a-time
loop in `S_find_span_end_mask`, as can be seen by comparing the
measurements from the previous couple of commits.
This commit tweaks that look to bring throughput of `S_find_next_masked`
up to the level of `S_find_span_end_mask`.
Before:
* find_next_masked /\A[^A]+/ 4741/s
Now:
* find_next_masked /\A[^A]+/ 9261/s
Still trumped by the step up to 512-bit scanning:
* find_next_masked \A[^A]+/ 16365/s
Still nice for the word-at-a-time loop to be zippier when finding the
actual position though.
Compare: https://github.com/Perl/perl5/compare/b27da4016d59...06de9aeef749
To unsubscribe from these emails, change your notification settings at
https://github.com/Perl/perl5/settings/notifications