Skip to content

perf: avoid repeatedly re-parsing frames - #27

Merged
P403n1x87 merged 5 commits into
P403n1x87:mainfrom
sparrowt:patch-1
Nov 20, 2023
Merged

perf: avoid repeatedly re-parsing frames#27
P403n1x87 merged 5 commits into
P403n1x87:mainfrom
sparrowt:patch-1

Conversation

@sparrowt

Copy link
Copy Markdown
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.
@codecov

codecov Bot commented Nov 15, 2023

Copy link
Copy Markdown

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
Copy Markdown
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

sparrowt commented Nov 16, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Owner

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

@sparrowt

sparrowt commented Nov 16, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Owner

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

@sparrowt

Copy link
Copy Markdown
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
@P403n1x87

Copy link
Copy Markdown
Owner

Awesome 🙌 Thanks a lot for your contributions! 🙂

@sparrowt

Copy link
Copy Markdown
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