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
{{ message }}
Repository navigation
StressTestDeepNestingOfConcat takes a lot longer on NonBacktracking than other engines #60645
I'm suspecting large overhead due to overlapping derivatives in unions (regexes) that are created due to ?. Looking at the alternative SymbolicNFA for computing derivatives to see a comparison as to how much these large unions (internally represented by dictionaries and hash-sets of SymbolicRegexNode) contribute would be a way to see if we can leverage SymbolicNFA, this is something I'll investigate with @olsaarik . At this point this is speculative.
@veanes, I just tried this test again, and it's gotten way worse than before. After minutes of it running, I attached a debugger, and I see the builder's node count in the hundreds of millions:
Can you please take a look? It seems like something has gone off the rails.
I'm investigating it. Been debugging and stepping through the code paths.
The problem is related to CreateDerivative of nested Concat with captures and OrderedOr with
simulateBacktracking=true, that causes the blowup. Some of this control-flow is new to me. To fully understand it I may need to discuss it with @olsaarik, I'll keep investigating for now to pinpoint the problem more exactly.
I was a bit stuck on this, but after a meeting yesterday with Olli, we figured out the cause.
The intermediate OrderedOr nodes are internalized as nodes in NFA mode (that must not happen) that causes the blowup and essentially defeats the purpose of the NFA mode.
I'm in the process of fixing this now.
I think they would be closed, I am currently implementing and testing necessary simplification rules that keep the derivatives small, e.g. ones such as Y|XY --> X?Y
and more importantly a rule such as X{0,n}?Y | X^nXY --> X{0,n+1}?Y where X^n stands for n explicit repetitions of X (X and Y are arbitrary regexes here)
otherwise the blowup of alternations still cause a intermediate blowup (despite the earlier fixes) in the stress tests
Activity
stephentoub commentedon Oct 19, 2021
cc: @veanes, @olsaarik
veanes commentedon Oct 20, 2021
I'm suspecting large overhead due to overlapping derivatives in unions (regexes) that are created due to
?. Looking at the alternativeSymbolicNFAfor computing derivatives to see a comparison as to how much these large unions (internally represented by dictionaries and hash-sets ofSymbolicRegexNode) contribute would be a way to see if we can leverageSymbolicNFA, this is something I'll investigate with @olsaarik . At this point this is speculative.stephentoub commentedon Apr 5, 2022
@veanes, I just tried this test again, and it's gotten way worse than before. After minutes of it running, I attached a debugger, and I see the builder's node count in the hundreds of millions:

Can you please take a look? It seems like something has gone off the rails.
veanes commentedon Apr 6, 2022
I'm investigating it. Been debugging and stepping through the code paths.
The problem is related to CreateDerivative of nested Concat with captures and OrderedOr with
simulateBacktracking=true, that causes the blowup. Some of this control-flow is new to me. To fully understand it I may need to discuss it with @olsaarik, I'll keep investigating for now to pinpoint the problem more exactly.
stephentoub commentedon Apr 6, 2022
Thanks.
veanes commentedon Apr 13, 2022
I was a bit stuck on this, but after a meeting yesterday with Olli, we figured out the cause.
The intermediate OrderedOr nodes are internalized as nodes in NFA mode (that must not happen) that causes the blowup and essentially defeats the purpose of the NFA mode.
I'm in the process of fixing this now.
joperezr commentedon May 4, 2022
@veanes was this fixed by #68307?
veanes commentedon May 4, 2022
working on it still, not fully fixed yet, but in the process
joperezr commentedon May 4, 2022
Got it, that's fine I know that you are working on some related changes but I was just wondering if this particular one could be closed or not.
veanes commentedon May 4, 2022
I think they would be closed, I am currently implementing and testing necessary simplification rules that keep the derivatives small, e.g. ones such as Y|XY --> X?Y
and more importantly a rule such as X{0,n}?Y | X^nXY --> X{0,n+1}?Y where X^n stands for n explicit repetitions of X (X and Y are arbitrary regexes here)
otherwise the blowup of alternations still cause a intermediate blowup (despite the earlier fixes) in the stress tests
veanes commentedon Jun 5, 2022
The issue is now fixed, by #69530.