Skip to content

use a dedicated render thread for indicatif spinner#23279

Draft
cburroughs wants to merge 1 commit into
pantsbuild:mainfrom
cburroughs:csb/indicatif-thread
Draft

use a dedicated render thread for indicatif spinner#23279
cburroughs wants to merge 1 commit into
pantsbuild:mainfrom
cburroughs:csb/indicatif-thread

Conversation

@cburroughs
Copy link
Copy Markdown
Contributor

Previously we had the classic combination of doing "real work" and trying to keep a UI snappy on the same (scheduler) thread. This results in jittery spinners that can be sluggish under load.

This change splits it out so there is a dedicated render thread. This matches the architecture used by the experimental-prodash renderer. The "obvious" alternative to get a steady tick would be enable_steady_tick, but that was rejected in #19931 due to desync concerns.

Using the large repo from #23236

$ asciinema record data/baseline.cast --command  '_PANTS_VERSION_OVERRIDE=2.31.0 PANTS_DEBUG= /home/ecsb/src/o/pants-trees/baseline/pants --no-pantsd --changed-since=HEAD~1 --changed-dependents=transitive list'

baseline: https://asciinema.org/a/b67xISILRXqBQl4U

after: https://asciinema.org/a/DK0s3SB6ISjab6ji

Notice: I used a LLM to try a variety of approaches to reduce jitter and to write the code for this particular restructuring. It is both the most clearly helpful, and a building block for anything else. I also used a LLM to write a script to analyze asciinema logs, but in this case the visual outcome was obvious.

Previously we had the classic combination of doing "real work" and
trying to keep a UI snappy on the same (scheduler) thread.  This
results in jittery spinners that can be sluggish under load.

This change splits it out so there is a dedicated render thread.  This
matches the architecture used by the `experimental-prodash` renderer.
The "obvious" alternative to get a steady tick would be
`enable_steady_tick`, but that was rejected in pantsbuild#19931 due to desync
concerns.

Using the large repo from pantsbuild#23236

```
$ asciinema record data/baseline.cast --command  '_PANTS_VERSION_OVERRIDE=2.31.0 PANTS_DEBUG= /home/ecsb/src/o/pants-trees/baseline/pants --no-pantsd --changed-since=HEAD~1 --changed-dependents=transitive list'
```

baseline: https://asciinema.org/a/b67xISILRXqBQl4U

after: https://asciinema.org/a/DK0s3SB6ISjab6ji

Notice: I used a LLM to try a variety of approaches to reduce jitter
and to write the code for this particular restructuring.  It is both
the most clearly helpful, and a building block for anything else.  I
also used a LLM to write a script to analyze asciinema logs, but in
this case the visual outcome was obvious.
@cburroughs cburroughs self-assigned this Apr 21, 2026
@cburroughs
Copy link
Copy Markdown
Contributor Author

@jsanders would you mind taking a look at this rust code?

Copy link
Copy Markdown

@jsanders jsanders left a comment

Choose a reason for hiding this comment

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

This all looks very reasonable to me!

cv.notify_all();
}
if let Some(h) = self.join_handle.take() {
let _ = h.join();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Arguably this could catch a panic in the thread, e.g. if let Err(e) = h.join() { log::warn!("indicatif render thread panicked: {e:?}"); }. But I think it's pretty common to ignore this. Up to you.

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