-
Notifications
You must be signed in to change notification settings - Fork 959
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
Progress bar rendering through indicatif is slow #10384
Comments
To understand the issue: Currently, there is a call to From what I understand, /// Draw to a buffered stderr terminal at a max of 20 times a second.
///
/// This is the default draw target for progress bars. For more
/// information see [`ProgressDrawTarget::term`].
pub fn stderr() -> Self {
Self::term(Term::buffered_stderr(), 20)
} However, it appears that the rate limiter only applies to progress bar ticks and not changing the text message. A call to This would mean that |
Actually, I think I was wrong. There is a call to However, attempting to change the rate here did not show different profiles: Line 20 in 68adadf
I've changed this to: Self::Default => ProgressDrawTarget::stderr_with_hz(1), and Self::Default => ProgressDrawTarget::stderr_with_hz(1000), @konstin Can you help me how to debug the issue? The profiles running your above command have quite some variance. |
I haven't looked into it in depth so i can't really help with the code. Usually, i try to optimize by e.g. counting how often the function was called myself or by inserting |
I've added a simple counter to invocations of If I set the frequency to the highest value (255), I get ~70 allowed events, however lower values also end up around 24 events. In addition, there is a burst mechanism in indicatif, which I haven't looked at yet. I think it's fair to say that there is not a lot of potential here by optimising the |
It looks like most of the time is spent in rendering the message, it may be possible to skip or delay the rendering until we actually (this is only a guess from the profile though) |
I've run some benchmarks using hyperfine on the file above:
What's most noticable is that there is a big jump from 0.5.15 to 0.5.16, and the latest release is just twice as fast. The local-noop version does nothing on I've tried setting different values I've also implemented a simple custom rate-limiter, that returns early in |
Currently, the uv resolver thread spends a considerable amount of time in
on_progress
->indicatif::style::ProgressStyle::format_state
. We should limit rendering progress bar updates to at most 1/60s, ideally directly in indicatif.Profile for
samply record --rate 20000 target/profiling/uv pip compile scripts/requirements/airflow.in
:The text was updated successfully, but these errors were encountered: