Repository navigation
Improve regex derivative construction - #69530
Conversation
Introduce new Effect node type that derivatives can include. Logic around derivative functions to translate Effect nodes to DerivativeEffect or just strip them away. Remove old AddTransitions derivative logic. Misc fixes to NFA support that was still assuming old unordered Or.
StripEffects now avoids repeated deduplication. The OrderedOr in the builder now does deduplication efficiently.
This reverts commit 11a2cfd.
Also remove concat loop rules
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsThe initial trigger for this PR was to fix issue #60645.
Concretely, a typical subsumption rule (avoiding alternation) is that
|
|
I didn't finish commenting everything I should. Will continue tomorrow morning. |
|
I think the state of comments for all the new code is relatively good now. Feel free to review! |
|
I'm planning to go through all the comments, want to do it now, ... but have a couple of meetings in the way. Back soon. |
|
/azp run runtime-libraries-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Outerloop tests look good; the stress tests are indeed passing now. The only regex thing popping up now is |
|
All comments seem to have been addressed at this point. I am sure there will be follow-up improvements going forward (e.g. more and improved subsumption checks, triggered by more evaluations and tests). But I think these belong to future PRs. |
Yes, that one is on me. I just opened #69692 to disable those tests for now. |
stephentoub
left a comment
There was a problem hiding this comment.
LGTM. There are some minor things we'll want to clean up further, but I'm going to merge to get it in for Preview 5, and to unblock subsequent work.
|
Sounds great! I'm continuing with the nfa-size-limit-PR, it will be great to work against the updated main, (getting this into main will have to wait for the next round but I'll push a PR for it soon, it will be accompanied by unit tests, that are important in this case for validation. Jose showed me how to set this up.) |
The initial trigger for this PR was to fix issue #60645.
There were several root causes behind the issue that surfaced through that stress test that are being fixed by this PR.
OrderedOris constructed. This needed a separate flagIsHighPriorityNullableto be maintained and a methodPruneLowerPriorityThanNullabilitythat extracts a backtracking derivative from a full derivative when transitions are computed in Backtracking-semantics-preserving mode. This implied a reduction of several quadratic behaviors that were caused by the earlier explicit expansion of transitions. Also caching became both easier to maintain and understand in this setting.(a?(a?(a?(a?....))))that create a lot of possible paths in the underlying NFA.(a(b(cd))))(e(fg))into(a(b(c(d(e(fg))))))Concretely, a typical subsumption rule (avoiding alternation) is that
Y|XYreduces toX??YifXis a nullable regex.This PR contains commits from me as well as @olsaarik.