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

perf: avoid repeatedly re-parsing frames #27

Merged
merged 5 commits into from
Nov 20, 2023
Merged

Conversation

sparrowt
Copy link
Contributor

Hi there! Thanks for producing such an excellent tool. This was a small optimisation I spotted while looking at stats.py to learn more about the Austin trace/profile file format.

This should reduce the effort on parsing frames by a factor of 4 when operating on a --full trace, because in that case ms will be a list of 4 metrics but we only need to parse the frames once because they are the same in all cases.

Also add a couple of comments in Metric.parse which weren't obvious to me on first reading, I hope that's ok.

This should reduce the effort on parsing frames by a factor of 4 when operating on a `--full` trace.

In that case `ms` will be a list of 4 metrics but we only need to parse the frames once because they are the same in all cases.

Also add a couple of comments which weren't obvious to me on first reading.
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (44f1c4a) 74.07% compared to head (88ca084) 74.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
+ Coverage   74.07%   74.08%   +0.01%     
==========================================
  Files          16       16              
  Lines        1508     1509       +1     
  Branches      218      219       +1     
==========================================
+ Hits         1117     1118       +1     
  Misses        328      328              
  Partials       63       63              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@P403n1x87
Copy link
Owner

@sparrowt Well spotted! Thanks a lot for your contribution 🙏 . I was thinking that perhaps something like a namedtuple or a dataclass would provide for a better API to collect profiles, instead of a plain list. But that's for another time 🙂 .

@P403n1x87 P403n1x87 changed the title Avoid repeatedly re-parsing frames perf: avoid repeatedly re-parsing frames Nov 15, 2023
@sparrowt
Copy link
Contributor Author

sparrowt commented Nov 16, 2023

True yes I think that could simplify things at some point!

I'm a bit confused by the type checking issue reported
EDIT: ahh hang on, I'm reassigning to frames which was the original str - I'll fix that

@P403n1x87
Copy link
Owner

Thanks. I think some sources need to be reformatted with black. Otherwise all seems good! 🙌

@sparrowt
Copy link
Contributor Author

sparrowt commented Nov 16, 2023

Ah I missed that check (I thought github was supposed to put all the failing ones at the top of the list...!) sorted now

@P403n1x87
Copy link
Owner

@sparrowt just checking whether there's an extra commit that still needs to be pushed to resolve the lining check 🙂

@sparrowt
Copy link
Contributor Author

Gah, sorted now. I thought I'd made the necessary changes after running black locally but I'd clearly missed one!

@P403n1x87 P403n1x87 merged commit 15efbf5 into P403n1x87:main Nov 20, 2023
19 checks passed
@P403n1x87
Copy link
Owner

Awesome 🙌 Thanks a lot for your contributions! 🙂

@sparrowt
Copy link
Contributor Author

Pleasure! In my limited local testing this was a 30% speedup which I'll take any day

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