[Perl/perl5] 568e6f: regex super-linear cache: make countdown unsigned
[email protected] (David Mitchell via perl5-changes)
| Newsgroups | perl.perl5.changes |
|---|---|
| Message-ID | <Perl/perl5/push/refs/heads/blead/[email protected]> |
Branch: refs/heads/blead
Home: https://github.com/Perl/perl5
Commit: 568e6fd238867bb9e99fa3f47cba3169009239e0
https://github.com/Perl/perl5/commit/568e6fd238867bb9e99fa3f47cba3169009239e0
Author: David Mitchell <[email protected]>
Date: 2026-08-08 (Sat, 08 Aug 2026)
Changed paths:
M regexec.c
Log Message:
-----------
regex super-linear cache: make countdown unsigned
The super-linear cache is a block of flag bits malloc()ed during regex
execution for patterns such as:
((aaa)+)+
which can go exponential in run time. The idea is that after the pattern
has been executing for a while, the cache is malloced(), and subsequent
failed iterations set a flag in the cache indicating a fail at this
position, so that it can be failed quickly if a similar point is
reached again after backtracking.
The "executing for a while" bit is determined by setting a counter to a
largish value, then counting down each time a WHILEM node is executed.
When the count reaches zero, the cache is malloc()ed. When the count
reaches -1, the cache becomes active, and no more decrements are done.
This commit changes it so that the zero and -1 above become 1 and 0.
This will allow the counter be made unsigned.
This commit's only side effect is that the SLC will become active one
iteration earlier than it did before. This isn't really an issue, as the
current count start value is an extremely vague heuristic: the value
used at the moment is (string length) x (the number of WHILEM nodes
which can participate in the SLC).
Actually changing the counter's type to unsigned will be done in the
next commit.
Commit: 54cf3d44cbbedd17d774e9a37921963e8fd5d0cb
https://github.com/Perl/perl5/commit/54cf3d44cbbedd17d774e9a37921963e8fd5d0cb
Author: David Mitchell <[email protected]>
Date: 2026-08-08 (Sat, 08 Aug 2026)
Changed paths:
M regexec.c
M regexp.h
Log Message:
-----------
regex: make superlinear cache 64-bit clean
(See the previous commit for an explanation of what the SLC is).
The iter and maxiter variables associated with the SLC are currently
declared as I32. This causes various possible issues, including
potential out of bounds reads and writes of the cache in the presence of
very large strings and many WHILEM nodes: for example when the string is
over 128Mb and there are 16 nodes (the max).
Following on from the previous commit which made iter never be negative,
this commit changes the variables' type to STRLEN (typically equal to
U64 on 64-bit systems) and does calculations in a way to avoid potential
overflows. If an overflow *could* occur, the cache isn't enabled.
Previously, a -ve overflow was "fixed" by setting maxiter to I32_MAX, and
+ve overflows weren't detected.
No tests are added, since this code only affects very large strings
using lots of memory and iterations, and such tests would crash on small
memory machines.
Commit: e75c3852ee50c9d0712b4a8da00f5e5880750b7c
https://github.com/Perl/perl5/commit/e75c3852ee50c9d0712b4a8da00f5e5880750b7c
Author: David Mitchell <[email protected]>
Date: 2026-08-08 (Sat, 08 Aug 2026)
Changed paths:
M regexec.c
Log Message:
-----------
regex enable DEBUG show of superlinear cache index
Allow poscache_iter and poscache_maxiter to be displayed when high
levels of regex debug are enabled.
Also, fix the indentation of the existing debugging message
"Detected a super-linear match"
Commit: 70e0bfa2068e5616440542bdc09d6fb2ab8db533
https://github.com/Perl/perl5/commit/70e0bfa2068e5616440542bdc09d6fb2ab8db533
Author: David Mitchell <[email protected]>
Date: 2026-08-08 (Sat, 08 Aug 2026)
Changed paths:
M regexec.c
Log Message:
-----------
regex: add comments about superlinear cache vars
document
reginfo->poscache_maxiter
reginfo->poscache_iter
Commit: f5b72e962a183effab9d6ead950339c3e7df243c
https://github.com/Perl/perl5/commit/f5b72e962a183effab9d6ead950339c3e7df243c
Author: David Mitchell <[email protected]>
Date: 2026-08-08 (Sat, 08 Aug 2026)
Changed paths:
M pod/perldelta.pod
Log Message:
-----------
perldelta for regex 64-bit super-liner cache
Commit: 9d16eaead9d9cbd3afc7a4e4aa010a138045ff44
https://github.com/Perl/perl5/commit/9d16eaead9d9cbd3afc7a4e4aa010a138045ff44
Author: David Mitchell <[email protected]>
Date: 2026-08-08 (Sat, 08 Aug 2026)
Changed paths:
M pod/perldelta.pod
M regexec.c
M regexp.h
Log Message:
-----------
[MERGE] regex: make superlinear cache 64-bit clean
plus various tweaks to docs, debugging etc
Compare: https://github.com/Perl/perl5/compare/852be0c8cb3c...9d16eaead9d9
To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications