Skip to content

More stack-related performance improvements #2844

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

Merged
merged 3 commits into from
May 12, 2025

Conversation

neoncube2
Copy link
Contributor

@neoncube2 neoncube2 commented May 8, 2025

Building off of #2835, this PR replaces the remaining instances of stack() with stack(0), so that we avoid getting context information for the first frame of the stack, which is expensive.

I also discovered that we were calling traceback.format_list(traceback.extract_stack()[-10:]), which does the following:

  1. Extract the entire stack
  2. Format the entire stack into strings
  3. Throw away everything except for the last 10 formatted frames of the stack

To fix this, I've made extract_stack() use the limit=10 parameter.

Finally, I optimized _path_utils.py to only retrieve two frames from the stack, instead of retrieving the entire stack and then discarding everything but the second frame :)

@neoncube2 neoncube2 closed this May 12, 2025
@neoncube2 neoncube2 reopened this May 12, 2025
@neoncube2
Copy link
Contributor Author

@mxschmitt Sorry, I accidentally closed and reopened the pull request '-_-

@mxschmitt mxschmitt merged commit 55b2800 into microsoft:main May 12, 2025
74 of 75 checks passed
@neoncube2 neoncube2 deleted the only-grab-needed-frames branch May 12, 2025 19:01
@neoncube2
Copy link
Contributor Author

@mxschmitt Woohoo, thanks! ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants