-
-
Notifications
You must be signed in to change notification settings - Fork 687
feat(engine): log elapsed time for completed workunits #22992
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
base: main
Are you sure you want to change the base?
feat(engine): log elapsed time for completed workunits #22992
Conversation
When a workunit completes, the log message now includes how long it took. For example: "Completed: Generate lockfile for foo (12.34s)" For operations taking 60 seconds or more, the format shows minutes: "Completed: Build target (2m 30.0s)" Co-Authored-By: Claude Opus 4.5 <[email protected]>
a16c307 to
0983a6a
Compare
benjyw
left a comment
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.
Thanks for the contribution! See comments.
src/rust/workunit_store/src/lib.rs
Outdated
| (WorkunitState::Completed { .. }, _) => "Completed:", | ||
| }; | ||
|
|
||
| // Format duration for completed workunits (not canceled ones) |
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.
This comment is superfluous (typical of LLM-generated code). It just restates what the code below it clearly does...
src/rust/workunit_store/src/lib.rs
Outdated
| let duration_str = if !canceled { | ||
| if let WorkunitState::Completed { time_span } = &self.state { | ||
| format_workunit_duration(std::time::Duration::from(time_span.duration)) | ||
| } else { |
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.
Why not show duration of incomplete workunits too?
src/rust/workunit_store/src/lib.rs
Outdated
| String::new() | ||
| } | ||
| } else { | ||
| String::new() |
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.
Seems weird to allocate a superfluous empty String for this. Better to use an Option and the format can use something like duration_str.as_ref().unwrap_or("")
|
@jasonwbarnett this partially implements this idea: #11965 |
0983a6a to
2248d22
Compare
Extract format_workunit_duration into a standalone function and add comprehensive unit tests covering: - Sub-second durations - Durations under 60 seconds - Boundary case at exactly 60 seconds - Durations with minutes and seconds - Zero duration Co-Authored-By: Claude Opus 4.5 <[email protected]>
2248d22 to
c58d943
Compare
| WorkunitState::Completed { time_span } => { | ||
| Some(format_workunit_duration(std::time::Duration::from(time_span.duration))) | ||
| } | ||
| WorkunitState::Started { start_time, .. } if canceled => { |
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.
So you only show the elapsed time if the work was canceled? Why? Wouldn't the opposite make more sense? Or just always show it?
|
Hi, just checking in on the status of this... |
Problem
When Pants completes a workunit (like generating a lockfile), the log message only shows that it completed, not how long it took:
This makes it difficult to identify slow operations or track performance over time.
Solution
Log the elapsed time alongside the completion message:
For longer operations (60+ seconds), show minutes:
Implementation
format_workunit_duration()helper function insrc/rust/workunit_store/src/lib.rslog_workunit_state()to include duration for completed (non-canceled) workunitsCloses #22991