-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(log): break timing-info message to multiple #16303
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
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.
Before I dig into this too much, do we need special messages for these or are there existing json messages from cargo we could use if we also log those? If not, are there existing rustc messages that we can translate into cargo messages to handle this?
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.
What Cargo --message-format=json emits today:
build-finished— for the entire build, not at per unit levelbuild-script-exectued— emitted after build script executioncompiler-artifact— emitted when a compiler artifact is produced for each rustc invocation.compiler-message— this is basically rustc diagonstics.timing-info— the unstable aggregated timing info. It is the same as the old timing-info log message before this PR.
None of them has any elapsed time information
What rustc has today:
diagnostic— just diagnosticsartifact— Notice when an artifact is written to disk. Contains file name and emit-type.future_incompat— for future incompat warningssection_timing— unstable section timing. Looks like{ "event": "start", /* Marks the "start" or "end" of the compilation section */ "name": "link", /* The name of the compilation section */ // Opaque timestamp when the message was emitted, in microseconds // The timestamp is currently relative to the beginning of the compilation session "time": 12345 }
I don't feel like there is anything we can directly use. timing-info Cargo message is half-broken. compiler-artifact has too much of information timing tracking doesn't need (but perhaps we'd like to expand to that in the future). We might not want to rely on section_timing's time field, as it is unclear what "beginning of the compilation" refers to.
The current approach gives us a room to iterate on our own at least.
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.
If we view this as a hack and document that we need to consolidate our messages, I'm fine moving forward with this.
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.
Yeah it is not the final version. I'd love to learn your thoughts on long-term consolidating our JSON messages and logging.
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 think we need to flesh out our json messages more
From #7614 (comment)
I think we should work to improve our json messages. The build analysis work is one area that will help shine a light on that. Another is the new cargo-fix architecture which would ideally have
cargo checklike progress while being a wrapper aroundcargo check, so we'll need json messages to support all of the progress reporting needs
If we log all json messages, we'll have redundancy with this.
From #t-cargo > build analysis log format @ 💬
would love for us to record all --message-format json messages
I also wonder if we should go with a full inverse, all logged messages are also json messages. Of course, we'll likely need to keep them distinct while the feature is unstable and we work through what we want the schema to be.
| "target": { | ||
| "kind": "lib", | ||
| "name": "bar" | ||
| }, |
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.
While this reduces content, it does deviate from our normal structure of json messages
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 am seeing timings message different from other messages. If users want details information, they should either inspect other messages or cargo metadata. Though if we want to be a bit consistent atm, fine with reusing the detailed Target struct.
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 think this ties into #16303 (comment)
| /// Emitted when a compilation unit starts. | ||
| UnitStarted { | ||
| package_id: PackageIdSpec, | ||
| target: Target, |
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.
This also is being inconsistent
Unblocked is a better term than unlocked
This is a preparation for adding unit-started event.
Instead of all unnecesary field, just track kind and in log. Detailed info can be retrieved from `cargo metadata` or other tools
Reduce log size by using an integer index instead of full metadata. The index is assigned deterministically at initialization.
4aae037 to
1ce4adb
Compare
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've noted schema questions in the tracking issue
Update cargo submodule 14 commits in 2a7c4960677971f88458b0f8b461a866836dff59..bd979347d814dfe03bba124165dbce9554d0b4d8 2025-11-25 19:58:07 +0000 to 2025-12-02 16:03:50 +0000 - fix(completion): Put host-tuple before actual tuples (rust-lang/cargo#16327) - fix(lints): use plural form correctly (rust-lang/cargo#16324) - fix(completions): include `all` in `cargo tree --target` candidates (rust-lang/cargo#16322) - fix(lints): show lint error number (rust-lang/cargo#16320) - chore(deps): update compatible (rust-lang/cargo#16318) - chore(deps): update crate-ci/typos action to v1.40.0 (rust-lang/cargo#16316) - Do not lock the artifact-dir for check builds + fix uplifting (rust-lang/cargo#16307) - Properly validate crate names in `cargo install` (rust-lang/cargo#16314) - Support --filter-platform=host for cargo metadata rust-lang/cargo#9423 (rust-lang/cargo#16312) - Update to mdbook 0.5 (rust-lang/cargo#16292) - refactor(clean): Better divide old / new layout (rust-lang/cargo#16304) - update: silent failure on non-matching package specs with --breaking (rust-lang/cargo#16276) - fix(log): break timing-info message to multiple (rust-lang/cargo#16303) - fix(clean): Clean hosts builds with new layout (rust-lang/cargo#16300)
What does this PR try to resolve?
Convert timing-info log messages from a single aggregated message per unit
to an event-based model that captures the build timings.
New events introduced:
unit-started- compilation begins (full metadata + index)unit-rmeta-finished-.rmetaartifact generated (with unlocked units)unit-section-{started,finished}- compilation phases (with section name)unit-finished- completion (with unlocked units)unit-startedChanges in old events:
timing-info— split to fiveunit-*eventsrebuild— thetargetfield now use a custom struct to show{ name, kind }, which should be good enough to distinguish different units.Part of #15844.
How to test and review this PR?
Test diffs should reflect the change.
A new test has bee added to showcase
-Zsection-timings(apparently we didn't have any test before).