-
Notifications
You must be signed in to change notification settings - Fork 535
perf(profiling): Performance tweaks to profile sampler #1789
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
perf(profiling): Performance tweaks to profile sampler #1789
Conversation
This contains some small tweaks to speed up the profiler. - changed from a namedtuple to a regular tuple as namedtuples were much slower but the tradeoff here is that it's more legible - moved away from `os.path.abspath` as it was doing some extra operations that were unnecessary for our use case
sentry_sdk/profiler.py
Outdated
# Make sure to keep in mind that the stack is ordered from the inner most | ||
# from to the outer most frame so be careful with the indexing. | ||
stack = tuple( | ||
prev_stack[prev_depth - (depth - i)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One benefit of this is that we're reusing the raw frame tuples across samples which helps with the overall memory usage as the number of duplicate frames across subsequent stacks can be a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 minor comments, feel free to ignore
very cool to use the previous sample as a cache!
This contains some small tweaks to speed up the profiler.
os.path.abspath
as it was doing some extra operations that were unnecessary for our use case