Skip to content
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

Avoid CallersFrames from escaping #1053

Merged

Conversation

prashantv
Copy link
Collaborator

@prashantv prashantv commented Jan 25, 2022

The runtime.CallersFrames method doesn't do much other than returning a struct pointer wrapping the passed in pcs. Calling this method twice ends up simplifying some of the logic (not having to format the first stack separately from the remaining), and ends up brining the performance of TakeStacktrace similar to master.

# benchstat comparing 3 runs of master vs this branch, each run using benchtime=10s
name            old time/op    new time/op    delta
TakeStacktrace    1.47µs ± 2%    1.48µs ± 2%   ~     (p=1.000 n=3+3)

name            old alloc/op   new alloc/op   delta
TakeStacktrace      496B ± 0%      496B ± 0%   ~     (all equal)

name            old allocs/op  new allocs/op  delta
TakeStacktrace      2.00 ± 0%      2.00 ± 0%   ~     (all equal)

@prashantv prashantv changed the title Avoid RuntimeFrames from escaping Avoid CallersFrames from escaping Jan 25, 2022
Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the case #1052 optimizes, this is slightly slower but still better overall. Worth it versus regressing on the other cases.

name \ time/op            master.txt  1052.txt    1053.txt
AddCallerAndStacktrace-8  869ns ± 4%  670ns ± 2%  761ns ± 2%

name \ alloc/op           master.txt  1052.txt    1053.txt
AddCallerAndStacktrace-8   665B ± 0%   449B ± 0%   657B ± 0%

name \ allocs/op          master.txt  1052.txt    1053.txt
AddCallerAndStacktrace-8   5.00 ± 0%   3.00 ± 0%   4.00 ± 0%

@abhinav abhinav merged commit 9cbe14e into uber-go:abg/share-stack-trace Jan 26, 2022
abhinav added a commit that referenced this pull request Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants