-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Make timings graphs scalable to user's window #15766
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
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
As an alternative to filling the screen by defaut, we could set the scaler so that the graph takes e.g. 75% of screen width, might be a bit less "eye-popping". |
What browsers have you tested on? |
Just Chrome, but that's essentially what most browsers use these days anyway 😆 Also tested in Firefox now, looks fine. |
Updated the implementation based on Zulip discussion. The PR description has been updated with the description of the current approach. |
const scaleElement = document.getElementById('scale'); | ||
scaleElement.min = width_to_graph_scale(MIN_GRAPH_WIDTH); | ||
scaleElement.max = width_to_graph_scale(MAX_GRAPH_WIDTH); | ||
scaleElement.value = width_to_graph_scale(window.innerWidth * 0.75); |
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.
Where is the 0.75
from?
Regardless, feel good, and we can always tweak if people find a better default. Thank you for the 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.
That is an arbitrary constant, to fit ~75% of the screen 😅
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.
I figured that. Anyway, I feel 75% is pretty balanced and eye-friendly.
Update cargo 8 commits in 6833aa715d724437dc1247d0166afe314ab6854e..9b296973b425ffb159e12cf3cd56580fd5c85382 2025-07-13 02:25:52 +0000 to 2025-07-25 17:10:08 +0000 - Allow using Cargo-as-a-library with gix's reqwest backend (rust-lang/cargo#15653) - Make timings graphs scalable to user's window (rust-lang/cargo#15766) - refactor: rename arg `mode` to `intent` (rust-lang/cargo#15774) - fix: `no-proc-macro` is overridden by subsequent edges (rust-lang/cargo#15764) - Use `gix` for `cargo package` (rust-lang/cargo#15534) - cargo-credential-libsecret: give FFI correctly-sized object (rust-lang/cargo#15767) - Remove unnecessary target-c-int-width from target specs (rust-lang/cargo#15759) - Expose artifact dependency getters in cargo-as-a-library (rust-lang/cargo#15753)
Update cargo 8 commits in 6833aa715d724437dc1247d0166afe314ab6854e..9b296973b425ffb159e12cf3cd56580fd5c85382 2025-07-13 02:25:52 +0000 to 2025-07-25 17:10:08 +0000 - Allow using Cargo-as-a-library with gix's reqwest backend (rust-lang/cargo#15653) - Make timings graphs scalable to user's window (rust-lang/cargo#15766) - refactor: rename arg `mode` to `intent` (rust-lang/cargo#15774) - fix: `no-proc-macro` is overridden by subsequent edges (rust-lang/cargo#15764) - Use `gix` for `cargo package` (rust-lang/cargo#15534) - cargo-credential-libsecret: give FFI correctly-sized object (rust-lang/cargo#15767) - Remove unnecessary target-c-int-width from target specs (rust-lang/cargo#15759) - Expose artifact dependency getters in cargo-as-a-library (rust-lang/cargo#15753)
Update cargo 8 commits in 6833aa715d724437dc1247d0166afe314ab6854e..9b296973b425ffb159e12cf3cd56580fd5c85382 2025-07-13 02:25:52 +0000 to 2025-07-25 17:10:08 +0000 - Allow using Cargo-as-a-library with gix's reqwest backend (rust-lang/cargo#15653) - Make timings graphs scalable to user's window (rust-lang/cargo#15766) - refactor: rename arg `mode` to `intent` (rust-lang/cargo#15774) - fix: `no-proc-macro` is overridden by subsequent edges (rust-lang/cargo#15764) - Use `gix` for `cargo package` (rust-lang/cargo#15534) - cargo-credential-libsecret: give FFI correctly-sized object (rust-lang/cargo#15767) - Remove unnecessary target-c-int-width from target specs (rust-lang/cargo#15759) - Expose artifact dependency getters in cargo-as-a-library (rust-lang/cargo#15753)
Update cargo 8 commits in 6833aa715d724437dc1247d0166afe314ab6854e..9b296973b425ffb159e12cf3cd56580fd5c85382 2025-07-13 02:25:52 +0000 to 2025-07-25 17:10:08 +0000 - Allow using Cargo-as-a-library with gix's reqwest backend (rust-lang/cargo#15653) - Make timings graphs scalable to user's window (rust-lang/cargo#15766) - refactor: rename arg `mode` to `intent` (rust-lang/cargo#15774) - fix: `no-proc-macro` is overridden by subsequent edges (rust-lang/cargo#15764) - Use `gix` for `cargo package` (rust-lang/cargo#15534) - cargo-credential-libsecret: give FFI correctly-sized object (rust-lang/cargo#15767) - Remove unnecessary target-c-int-width from target specs (rust-lang/cargo#15759) - Expose artifact dependency getters in cargo-as-a-library (rust-lang/cargo#15753)
What does this PR try to resolve?
This PR changes the way the charts produced by
cargo build --timings
scale. It changes the scale slider so that its min/max values adapt to the duration of the build, to allow zooming in/out even for very short build durations. It also automatically initializes the scale value based on the client's window width.The number of pixels per second per scale value has been changed from 1 to 8, to avoid having too many scale values for the given duration of supported chart widths, which I have determined in this PR to be
[200, 4096]
pixels.scalable-timings.mp4
How to test and review this PR?
Run
cargo build --timings
e.g. on https://github.com/BurntSushi/ripgrep. Then open the resulting page in a browser, and try to enlarge/ensmall the window (possibly using mobile emulation), and see how the charts react to window size.Fixes: #15666