-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
very slow DFA construction (resulting in a very large DFA) #128
Comments
This partially fixes bug #128: "very slow DFA construction (resulting in a very large DFA)". DFA construction is no longer slow, but the resulting DFA is still too large and needs to be minimized.
Assuming the same example:
Commit b98997b reduces the time of DFA construction from ~115s to ~1.2s:
The generated DFA is still too big and should be minimized. |
…ery large DFA)". After minimization the resulting DFA is much smaller: /*!re2c [ac]{0,14} [a] [ac]{0,14} {} */ Was: $ time re2c slow.re > slow.c && stat -c '%s' slow.c real 1m54.837s user 1m54.733s sys 0m0.120s 5627102 Now: $ time ./re2c slow.re > slow.c && stat -c '%s' slow.c real 0m0.732s user 0m0.684s sys 0m0.048s 15078
DFA size is reduced by commit 1136f2f that adds DFA minimization.
|
The intermediate DFA (the one that is constructed by NFA determinization and further reduced by DFA minimization) is still large. We'll need incremental minimization to fully solve pathological cases like this. Closing the bug until someone encounters a real-world example. |
Consider the following code (slow.re):
It takes re2c a long time to compile this code and the generated lexer is very large:
Increasing repetition counter (any of the two, or both):
Causes insane increase of time and size:
If we minimize the generated DFA, it would get reasonably small. (I experimented with minimization a bit; the number of states is reduced by several orders of magnitude and the minimization itself takes reasonable time, which suggests that the slowdown might be caused by inefficiency in FSA determinisation).
The text was updated successfully, but these errors were encountered: