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
Refactor Execute Timings to use an enum-indexed array structure #23085
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Thanks for taking this on ❤️
75d31e5
to
9e48fbc
Compare
Codecov Report
@@ Coverage Diff @@
## master #23085 +/- ##
=======================================
Coverage 81.2% 81.2%
=======================================
Files 564 564
Lines 153429 153454 +25
=======================================
+ Hits 124649 124707 +58
+ Misses 28780 28747 -33 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks again for picking this up!
Of course, it was fun! Please let me know if there are other issues like this lying around 😄 |
program-runtime/src/timings.rs
Outdated
|
||
pub fn saturating_add_in_place(&mut self, timing_type: ExecuteTimingType, value_to_add: u64) { | ||
let idx = timing_type as usize; | ||
let res = self.metrics[idx].saturating_add(value_to_add); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though I see its safe here, direct indexing makes me nervous from a panic standpoint. Could use get_mut
here and ignore if index is out of bounds. Also a debug assert on the index might be helpful
core/src/progress_map.rs
Outdated
("store_us", self.execute_timings.store_us, i64), | ||
( | ||
"check_us", | ||
self.execute_timings.metrics[ExecuteTimingType::CheckUs], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These direct indexes worry me to, safe here, yes, safe in the future, ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, thanks for pointing this out! I tried wrapping the array in a newtype to prevent users from calling timings.metrics[<bad_usize>]
. Let me know if there's a better alternative.
Thanks for the contribution, looking good, couple of nits |
Pull request has been modified.
48f58c2
to
f321fa7
Compare
Problem
The
ExecuteTimings
type was getting a bit complex and clunky to use. Context hereThis is my first attempt at a contribution, so I'm new to the codebase (and to Rust). I saw this issue hasn't been active for over a month, so I decided to take a stab at it.
Any feedback is appreciated, thank you! (@t-nelson or anyone else)
Summary of Changes
ExecuteTimings
with an enum-indexed array.saturating_add
A few questions:
std::ops::Index
?Metrics
type?Fixes #22325
Consider refactoring ExecuteTimings type