-
Notifications
You must be signed in to change notification settings - Fork 84
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
Exponential processing time increase with case statement nested parentheses #1075
Comments
FYI: I have tested this with CakeML v2648 and it still seems to be an issue. |
Thanks for the report and the code. I looked into it and this looks like exponential behavior in the parser, so perhaps something @mn200 could comment on. For example: finished: start up
finished: lexing and parsing --- 24654 milliseconds
... finished: start up
finished: lexing and parsing --- 47164 milliseconds
finished: type inference --- 15 milliseconds
... (the rest of the compiler seems to run normally after parsing) |
Would you mind mentioning how you got that debug output? Would likely prove helpful for me in other work using CakeML. |
Sure, you will need to bootstrap the CakeML compiler with its debugging output turned on. If you have the latest release files and
This will produce
This version of the compiler will print the debugging output when compiling files but note that |
I will try to look into this! |
So, the problem is not solved yet, but I think I understand the issue now. It is to do with the way the The root of it is a classic SML problem with how the naïve grammar would see
as ambiguous (which |
Thank you for looking into it, glad the issue seems to have been located and hopefully a fix should not be too difficult |
Throughout I am utilizing CakeML v2274.
Given two programs, one with and one without nested parentheses in case statements:
vs.
The time it takes to run
cake < fib.cml > /dev/null
for the one WITH parentheses will take much longer than the one without.In particular, I generated the following benchmark showing the exponential increase given the nesting depth:
Code used to generate benchmark
Another thing I will mention, I tried testing this with
if
statements and did not see the same exponential increaseThe text was updated successfully, but these errors were encountered: