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

Optimize stacktrace from 7.36kB to 2.30kB and speed too #467

Merged
merged 3 commits into from Aug 31, 2022

Conversation

YaroslavPodorvanov
Copy link
Contributor

@YaroslavPodorvanov YaroslavPodorvanov commented Aug 20, 2022

go test ./... -run=$^ -bench=Benchmark -benchmem -count=10 > old.txt
go test ./... -run=$^ -bench=Benchmark -benchmem -count=10 > new.txt
benchstat old.txt new.txt
name              old time/op    new time/op    delta
ProcessEvent-12     1.50µs ±14%    1.56µs ±22%     ~     (p=0.684 n=10+10)
NewStacktrace-12    8.24µs ±25%    4.34µs ±14%  -47.30%  (p=0.000 n=10+10)

name              old alloc/op   new alloc/op   delta
ProcessEvent-12       946B ± 0%      939B ± 0%   -0.73%  (p=0.000 n=10+7)
NewStacktrace-12    7.36kB ± 0%    2.30kB ± 0%  -68.70%  (p=0.000 n=10+10)

name              old allocs/op  new allocs/op  delta
ProcessEvent-12       4.00 ± 0%      4.00 ± 0%     ~     (all equal)
NewStacktrace-12      15.0 ± 0%       4.0 ± 0%  -73.33%  (p=0.000 n=10+10)

frames = append([]Frame{
NewFrame(callerFrame),
}, frames...)
frames = append(frames, NewFrame(callerFrame))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is main optimization of NewStacktrace because append faster that prepend and use less memory

@YaroslavPodorvanov
Copy link
Contributor Author

@kamilogorek can you review please?

@YaroslavPodorvanov YaroslavPodorvanov changed the title Optimize Optimize attempt (Stacktrace from 7.36kB to 2.30kB) Aug 20, 2022
@YaroslavPodorvanov YaroslavPodorvanov changed the title Optimize attempt (Stacktrace from 7.36kB to 2.30kB) Optimize stacktrace from 7.36kB to 2.30kB and speed too Aug 26, 2022
@YaroslavPodorvanov
Copy link
Contributor Author

@bruno-garcia can you review code?

@kamilogorek
Copy link
Contributor

@YaroslavPodorvanov I'll catch up on everything this week. We had company-wide hackweek, so everyone was slow to review external contributions :)

@kamilogorek kamilogorek merged commit 5e27377 into getsentry:master Aug 31, 2022
@kamilogorek
Copy link
Contributor

kamilogorek commented Aug 31, 2022

Thanks 🙇

@YaroslavPodorvanov YaroslavPodorvanov deleted the review-optimize branch August 31, 2022 19:32
@YaroslavPodorvanov YaroslavPodorvanov restored the review-optimize branch August 31, 2022 19:32
@YaroslavPodorvanov YaroslavPodorvanov deleted the review-optimize branch September 27, 2023 19:04
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.

None yet

3 participants