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

Allow to specify the output file for --timings #12898

Open
glandium opened this issue Oct 31, 2023 · 5 comments
Open

Allow to specify the output file for --timings #12898

glandium opened this issue Oct 31, 2023 · 5 comments
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` S-triage Status: This issue is waiting on initial triage.

Comments

@glandium
Copy link
Contributor

Problem

Using cargo build --timings creates a target/cargo-timings/cargo-timing-YYYYMMDDTHHMMSSZ.html file as well as a symbolic link target/cargo-timings/cargo-timing.html. The only way to reliably know the exact file that a specific invocation of cargo has created is to parse its output and look for "Timing report saved to" (relying on the symbolic link is not time-resistant).

Proposed Solution

It would be useful to allow e.g. cargo build --timings=/path/to/my-report.html that would make cargo create said file instead of target/cargo-timings/cargo-timing-YYYYMMDDTHHMMSSZ.html. Whether it should skip creating a symbolic link or not is an open question.

--timings=html and timings=json would still have their current meaning, and the extension of the file would determine the format (i.e. --timings=/path/to/report.json would create a file with the json format)

Notes

No response

@glandium glandium added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Oct 31, 2023
@epage
Copy link
Contributor

epage commented Oct 31, 2023

Could you expand on why you need to know the file and why this solution works better compare to the symlink?

@epage epage added the A-timings Area: timings label Oct 31, 2023
@glandium
Copy link
Contributor Author

Stupid example: Run cargo build --timings and cargo build --timings --release at the same time in two terminals. Without looking at the output in each terminal, how do you tell which html file is from which build?

Now, that's not a super-realistic example, but consider something like a build system that invokes cargo to build two different crates in a workspace, the second of which already has been built, so that by the time the build system has figured the first has finished and looks at the symlink, the second, which was a no-op already changed the symlink.

@weihanglo
Copy link
Member

I had a vague impression that the Cargo team had a discussion about storing timing data in a SQLite-ish local database, and might want to extend those data as profiles for future PGO in Cargo. If that is going to be implemented, this proposal might be less useful.

So put it in a broader scope — Cargo should have a reliable way to persist and retrieve timing data, might be related to #10410.

@epage
Copy link
Contributor

epage commented Oct 31, 2023

Such an effort could have some synergy with #1989 and #2904

We could have cargo report rebuild, cargo report timings, etc.

@Aranjedeath
Copy link

I am also interested in a solution to this problem, perhaps not the same as OP but a solution nonetheless. I am regularly running cargo build --release --timings, and at one point realized these are stored in the project folder by default. Which means all the timings outputs are wiped out if you try to throw git in the sea and start over.

I was originally hoping for a ... default output location such as ~/.cargo/timings/* (or whatever would be similar and appropriate). I can also see a second issue after reading the back and forth here, which is that the current file name is timestamp-based and so does not really communicate anything about the build itself. It could.

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` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

4 participants