Skip to content
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

Closed
matthiaskrgr opened this issue Sep 18, 2019 · 8 comments · Fixed by #12420
Closed

--timings: show crate version in the graph? #7384

matthiaskrgr opened this issue Sep 18, 2019 · 8 comments · Fixed by #12420
Labels
A-timings Area: timings C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@matthiaskrgr
Copy link
Member

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
syn
)

@matthiaskrgr matthiaskrgr added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Sep 18, 2019
@matthiaskrgr matthiaskrgr changed the title -Ztimings: show crate version -Ztimings: show crate version in the graph? Sep 18, 2019
@ehuss ehuss added the A-timings Area: timings label Sep 20, 2019
@ehuss ehuss changed the title -Ztimings: show crate version in the graph? --timings: show crate version in the graph? Jul 13, 2022
@m-bal
Copy link

m-bal commented May 7, 2023

I would like to take a crack at this. I understand the team doesn't accept new features without the S-accpeted label, but I thought I'd ask in case. Is it okay to work on this?

@weihanglo
Copy link
Member

weihanglo commented May 7, 2023

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 weihanglo added S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review E-easy Experience: Easy labels May 7, 2023
@m-bal
Copy link

m-bal commented May 11, 2023

... when they need to disambiguate.

@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 (units)? If so, would creating a list of duplicate crates with a different version, then checking that list when creating the label and adding the version be a sufficient implementation?

@weihanglo
Copy link
Member

Yep. unit.pkg or something else should be sufficient to disambiguate.

@remkop22
Copy link

I don't see any progress on this. Would it be okay if I picked this up?

@weihanglo
Copy link
Member

@remkop22, not sure whether @m-bal already started or not. Since it was a month ago, it's probably fine for you to take over I guess.

Feel free to ask questions here!

@Angelin01
Copy link
Contributor

Angelin01 commented Jul 28, 2023

@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);

Which gives this result:
image

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.
Is this acceptable?

@weihanglo
Copy link
Member

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 syn v2.0.18 since the table below uses this format. Having the same format make it easy to do text search)

bors added a commit that referenced this issue Aug 1, 2023
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.
@bors bors closed this as completed in 63ec5e2 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-timings Area: timings C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants