You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A long line of repeated *a_ parses in quadratic time. The mirrored _a* is linear:
$ python3 -c "print('*a_' * 400000, end='')"> star.md # 1.2 MB
$ time cargo run --release < star.md > /dev/nullreal 0m26.8s
$ python3 -c "print('_a*' * 400000, end='')"> under.md
$ time cargo run --release < under.md > /dev/nullreal 0m0.06s
On main (c574292), release build, *a_ at 30, 60, 120, 240 and 480 KB takes 0.016, 0.054, 0.24, 0.93 and 3.7 s, while _a* stays under 0.04 s.
Every _ in that line can close but not open, and finds no _ opener, so find_match calls set_lowerbound. For an underscore that can't open, that raises only UNDERSCORE_NOT_BOTH. get_lowerbound for the next one takes the min of that slot and UNDERSCORE_BASE + count % 3, which is still 0, so each _ rescans the whole stack of * openers. Asterisks raise both slots. The difference came in with 71cf581, which added the % 3 slots for underscores.
This is a different pattern from #1076. The dos-fuzzer doesn't flag it: at its 32 KB size the line parses in about 2.7 ms and still looks linear.
Activity