Skip to content

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

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Jul 22, 2025

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

@rustbot
Copy link
Collaborator

rustbot commented Jul 22, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-timings Area: timings S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2025
@Kobzol
Copy link
Member Author

Kobzol commented Jul 22, 2025

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".

@epage
Copy link
Contributor

epage commented Jul 22, 2025

What browsers have you tested on?

@Kobzol
Copy link
Member Author

Kobzol commented Jul 22, 2025

Just Chrome, but that's essentially what most browsers use these days anyway 😆 Also tested in Firefox now, looks fine.

@Kobzol Kobzol force-pushed the scalable-timings branch from 18fd891 to d4f414d Compare July 25, 2025 06:49
@Kobzol
Copy link
Member Author

Kobzol commented Jul 25, 2025

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);
Copy link
Member

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!

Copy link
Member Author

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 😅

Copy link
Member

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.

@weihanglo weihanglo added this pull request to the merge queue Jul 25, 2025
Merged via the queue into rust-lang:master with commit 1d5d0ba Jul 25, 2025
24 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2025
@Kobzol Kobzol deleted the scalable-timings branch July 25, 2025 16:16
bors added a commit to rust-lang/rust that referenced this pull request Jul 25, 2025
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)
bors added a commit to rust-lang/rust that referenced this pull request Jul 25, 2025
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)
@rustbot rustbot added this to the 1.90.0 milestone Jul 26, 2025
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jul 28, 2025
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)
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Jul 28, 2025
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-timings Area: timings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timings graph should fit the screen by default
5 participants