-
Notifications
You must be signed in to change notification settings - Fork 249
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
Only get draw_target-width when we actually draw #683
Conversation
@djc Tests pass locally now. |
Actually, this is not working, since |
Should (hopefully) work now. The contrast in speed is actually bigger when using |
@djc Let me know if you need any else for this PR. |
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.
LGTM modulo some small nits.
Would be nice if you can squash your commits.
Thanks for these performance wins. Do you have more in the pipeline? Would you like a release once these are merged?
src/state.rs
Outdated
// `|= self.is_finished()` should not be needed here, but we used to always draw for | ||
// finished progress bars, so it's kept as to not cause compatibility issues in weird cases. | ||
force_draw |= self.state.is_finished(); | ||
|
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.
Nit: please avoid unrelated cosmetic changes.
src/draw_target.rs
Outdated
|
||
pub(crate) fn width(&self) -> Option<u16> { | ||
match self { | ||
Drawable::Term { term, .. } => Some(term.size().1), |
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.
Nit: please use Self
instead of Drawable
here.
accfa17
to
9f0fb9c
Compare
Thanks for the review! I've addressed your comments. I don't have any more changes (besides #684) planned. I wanted to look into some basic benchmarking to see if there are any other possible performance improvements. |
When calling
BarState::draw
, there is a call toself.draw_target.width()
.However, that operation can be expensive and the width is not needed, if there is no draw-target.
Thus, this PR delays the calling
.width()
if there is not target to draw to.For comparison, I've used this minibenchmark:
Using the latest release it runs in about 400ms, whilst the fixed version uses about 100ms.
The issue surfaced with uv, when resolving many packages: astral-sh/uv#10384