The issue is unlikely to be specific to the absence operator, I think it affects any case where a regexp takes a long time due to backtracking. In addition to allowing interrupts, the pull request also allows yielding to other threads during a long regexp match (since checking for interrupts has that effect).
Updated by jeremyevans (Jeremy Evans) over 4 years ago
Actions
This change degrades the performance of regular expression matching when frequent backtracking occurs.
Before edc8576a65b7082597d45a694434261ec3ac0d9e
$ time ./miniruby -ve '/^a*b?a*$/ =~ "a" * 20000 + "x"'
ruby 3.2.0dev (2022-03-10T19:06:33Z master edc8576a65) [x86_64-linux]
real 0m3.824s
user 0m3.820s
sys 0m0.004s
After edc8576a65b7082597d45a694434261ec3ac0d9e
$ time ./miniruby -ve '/^a*b?a*$/ =~ "a" * 20000 + "x"'
ruby 3.2.0dev (2022-03-10T19:06:33Z master edc8576a65) [x86_64-linux]
real 0m4.608s
user 0m4.588s
sys 0m0.016s
I have no idea if this may lead to any actual problem, but how about reducing the frequency of rb_thread_check_ints? This PR makes the check only once every 128 backtracks.