-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
--timings: show crate version in the graph? #7384
Comments
I would like to take a crack at this. I understand the team doesn't accept new features without the |
Hi, @m-bal. Thank you for being interested in this. I feel like we could display the version (or source) when they need to disambiguate. Some pointers:
|
@weihanglo Do you mean only add the crate version if we see a duplicate crate (same crate name) with a different version in the list of crates ( |
Yep. |
I don't see any progress on this. Would it be okay if I picked this up? |
@weihanglo Pardon my intrusion as I believe there's two people that said they'd fix this issue, but I took a quick look at the code you linked and I do believe the solution is as simple as this patch: diff --git a/src/cargo/core/compiler/timings.js b/src/cargo/core/compiler/timings.js
index 986070ab0..92f57fb9a 100644
--- a/src/cargo/core/compiler/timings.js
+++ b/src/cargo/core/compiler/timings.js
@@ -111,7 +111,7 @@ function render_pipeline_graph() {
ctx.textAlign = 'start';
ctx.textBaseline = 'middle';
ctx.font = '14px sans-serif';
- const label = `${unit.name}${unit.target} ${unit.duration}s`;
+ const label = `${unit.name}${unit.target} (v${unit.version}) ${unit.duration}s`;
const text_info = ctx.measureText(label);
const label_x = Math.min(x + 5.0, canvas_width - text_info.width - X_LINE);
ctx.fillText(label, label_x, y + BOX_HEIGHT / 2); It doesn't only mark the version when there are duplicate crates, but in my opinion this is more "honest" as the version is shown at all times, making visual comparisons easier. |
Hey @Angelin01, thanks for being interested in this! My original idea is that duplicate crates are minority, so it may be worth showing versions only when there are really duplicates to reduce visual noise. I don't really have a strong opinion, and it is easy to revert if people feel too noisy then. So, go ahead! (BTW I may display it as |
Display crate version on timings graph ### What does this PR try to resolve? Fixes #7384 The solution here is the simplest one: since duplicate crates with different versions can cause confusion, we always output the version. ### How should we test and review this PR? Build any create using the `--timings` option: ``` cargo build --timings ``` and verify the resulting HTML file. ### Additional information The formatting is consistent with how the crates are displayed in the terminal output for Cargo and also on the table below the graph. Initially, [this comment](#7384 (comment)) suggested said formatting for ease of searching, but I do believe the browser can't search in the graph itself. Sample console output: ``` Compiling lazycell v1.3.0 Compiling unicode-xid v0.2.4 Compiling unicode-width v0.1.10 Compiling glob v0.3.1 Compiling curl-sys v0.4.65+curl-8.2.1 Compiling curl v0.4.44 Compiling git2 v0.17.2 ``` Sample rendered HTML output: ![image](https://github.com/rust-lang/cargo/assets/17818024/23aae84e-5107-4352-8d0f-ecdfcac59187) ### Possible issues and future work A possible issue in this solution is that the output becomes too noisy. Other possible solutions: - Only display the version if there are two "units" with the same name. One possible implementation is to count the names, aggregate them in a simple map and look it up during rendering. - Create a small selection to select the disambiguate method between "Never", "Always" and "Only duplicates". This may be overkill.
When different dependencies pull in multiple versions of the same crate, it would help to see the version of the crate that was compiled. (See syn when building rustfmt
)
The text was updated successfully, but these errors were encountered: