Repository navigation
fixes in transition blowup and removing recursion from RegexNode conversion - #68307
Conversation
…tToSymbolicRegexNode
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsPartially addressing active issue #60645.
The use of
|
|
The last commit fixes the above comments. |
|
I think this is good point in time to merge this PR into main, if the fixes I did look fine, and no more comments remain. |
| } | ||
| } | ||
|
|
||
| public override string ToString() |
There was a problem hiding this comment.
can this ToString be debug only?
| public Node(T elem, Node? prev, Node? next) { _elem = elem; _prev = prev; _next = next; } | ||
| } | ||
|
|
||
| public override string ToString() |
There was a problem hiding this comment.
can this ToSTring be debug only?
There was a problem hiding this comment.
Indeed, both ToString()'s are used for debugging purposes only, forgot to mark them as such.
There was a problem hiding this comment.
I could do a quick follow-up fix PR, unless someone else takes care of this inside another PR, as this is a trivial change that perhaps does not warrant a separate PR.
There was a problem hiding this comment.
Well, I'll remember to do it in my upcoming PR (regarding upper bound measuring of NFA states).
Partially addressing active issue #60645.
The issue is not fully fixed yet after this pr since more related performance issues are still present.
But at least three key fixes are made, so the PR made sense at this time.
Removing quadratic increase in transition creation, through
TransitionListdata structure inAddTransitionsmethod.Removing deep recursion in
ConvertToSymbolicRegexNode(RegexNode)that turned out to be a bottleneck in many stress tests leading to calls ofStackHelper.CallOnEmptyStackand construction times in the order of 10sec that was reduced 100x, by rewriting the method with a while loop and local cache of intermediate results.Added
DoublyLinkedListdata structure in order to construct lists of symbolic regex nodes that can be extended both at the start and at the end, as well as append to inO(1)cost, and allows walking the list forwards and backwards linearly in the length of the list. It avoids locally creating multiple creations of intermediate transition arrays and mainly avoids deep nesting of concatenations involving captures.The use of
DoublyLinkedListinConvertToSymbolicRegexNoderelies on the property thatno
RegexNodeobject is repeated in the ASTwhich must be true, since any two different occurrences of
RegexNodeobject must also be distinct references. CorrespondingDebug.Assertcalls are also made to make sure that this is indeed the case.