Skip to content

reduce workunit terminal display to one decimal#23215

Open
cburroughs wants to merge 1 commit intopantsbuild:mainfrom
cburroughs:csb/spinner-decimal
Open

reduce workunit terminal display to one decimal#23215
cburroughs wants to merge 1 commit intopantsbuild:mainfrom
cburroughs:csb/spinner-decimal

Conversation

@cburroughs
Copy link
Copy Markdown
Contributor

@cburroughs cburroughs commented Apr 3, 2026

Currently we have a render rate of 10 Hz

pub fn render_rate_hz() -> u8 {
but try to display out to two decimal places. This results in some awkward displays where the last digit will look stuck -- 1.25 --> 1.35 --> 1.45 -- until some jitter aligns it to a new digit for a bit. Since this is just for a visual display and humans can't actually count that fast, I think it's fine to show one digit after the decimal. This is the granularity of docker for example.

Before: https://github.com/user-attachments/assets/c8ab5bf5-3336-44f2-ba14-76b887160715

After: https://github.com/user-attachments/assets/73b18e94-9097-49c9-a493-3e748ad5ccb2

An alternative approach would be to render at 100 Hz, but I don't think displaying the digit just to "look cool" is worth becoming terminal performance experts.

Disclosure: Claude connected the render_interval/render_rate_hz/render math together, and made the change.

Currently we have a render rate of 10 Hz
<https://github.com/pantsbuild/pants/blob/9b3c1562e2081d8e60433341ad8dc5585ec37323/src/rust/ui/src/lib.rs#L38>
but try to display out to two decimal places.  This results in some
awkward displays where the last digit will look stuck -- 1.25 --> 1.35
--> 1.45 -- until some jitter aligns it to a new digit for a bit.
Since this is just for a visual display and humans can't actually
count that fast, I think it's fine to show one digit after the
decimal.  This is the granularity of `docker` for example.

Before:

After:

An alternative approach would be to render at 100 Hz, but I don't
think displaying the digit just to "look cool" is worth becoming
terminal performance experts.
@cburroughs cburroughs self-assigned this Apr 3, 2026

pub fn format_workunit_duration_ms(duration: Duration) -> String {
format!("{:.2}s", (duration.as_millis() as f64) / 1000.0)
format!("{:.1}s", duration.as_secs_f64())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not a rust expert, but my impression is that this is more idiomatic following the stabilization of https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f64

@cburroughs cburroughs marked this pull request as ready for review April 3, 2026 17:58
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.

1 participant