Skip to content

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

Merged
merged 13 commits into from
Jan 5, 2023

Conversation

Zylphrex
Copy link
Member

@Zylphrex Zylphrex commented Dec 16, 2022

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
  • use the previous sample as a cache while sampling

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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@Zylphrex Zylphrex requested review from sl0thentr0py, antonpirker and a team December 16, 2022 22:43
# 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)]
Copy link
Member Author

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.

antonpirker and others added 7 commits December 19, 2022 12:35

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…ampler

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@sl0thentr0py sl0thentr0py self-assigned this Jan 5, 2023
Copy link
Member

@sl0thentr0py sl0thentr0py left a 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!

@Zylphrex Zylphrex enabled auto-merge (squash) January 5, 2023 15:47
@Zylphrex Zylphrex merged commit 2f916d3 into master Jan 5, 2023
@Zylphrex Zylphrex deleted the txiao/perf/performance-tweaks-to-profile-sampler branch January 5, 2023 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants