-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Stack growth defeats optimization #1527
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
Comments
I'm having a hard time understanding what I'm seeing. The above numbers are with the following main function:
If I instead use this main function:
Thin I get the following results with -O:
It should be doing less work but it's taking longer. |
With the smaller main function for some reason a lot of time ends up being spent in check_stack_canary. |
check_stack_canary does take a lot of time, but removing it doesn't change the general behavior here that -O is slower and the smaller main function is slower. |
Setting RUST_MIN_STACK=1000000 results in the optimized code being much faster. |
My guess is that the optimized code needs less stack, so it spends more time at the bottom of the stack where segments are smaller, and ends up making more requests to grow/shrink the stack |
Adding this back to the library as a stopgap measure to recover some benchmark performance. See #1527.
I checked in some optimizations to stack growth that makes it perform much better. The optimized version of fib is still slightly worse than the unoptimized one, but I don't what else to do about it. |
After adding a call to fib(42) in shootout-fibo's main function.
Without -O:
With -O:
Edit: When tasks do a lot of calculations without using a lot of stack, the effects of growing and shrinking the stack appear to have terrible results.
The text was updated successfully, but these errors were encountered: