-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Merge -Zhir-stats
into -Zinput-stats
#133023
Conversation
AST and HIR are two separate IR's with a different structure. As such they should get separate statistics. |
Not too familiar with the use case for this, maybe r? @nnethercote? |
@bjorn3 I understand that, but the reason I'm asking is because |
Right, missed that.
I never used either flag, so I guess I'm not the right person to decide whether that should be done or not. |
The code changes here look fine. You should update the test. It's current marked as As for the bigger questions about the two flags:
@samestep: Would you like to do this? You could do it in this PR, in a second commit. Finally, I'm curious why you were looking at these flags. Have you been using them yourself? |
Changes to the size of AST and/or HIR nodes. cc @nnethercote |
|
-Z hir-stats
-Zhir-stats
into -Zinput-stats
Thanks for the quick review!
Done; yeah, I am on an M-series Mac.
I've merged them, but I missed the part about
Done.
It's a bit of a long story, and somewhat off-topic for this thread, so I'll write you an email. |
Looks good. My only suggestion is to squash the first two commits together, because they are logically part of the same change. Once that's done it's good to go, thanks. @bors delegate=samestep |
✌️ @samestep, you can now approve this pull request! If @nnethercote told you to " |
14feb60
to
090c24f
Compare
@nnethercote done; what should I do now? (I haven't interacted with bors before, sorry!) |
@bors r+ |
Oh oops I didn't realize it had to be in its own message, sorry again! For some reason I thought your message yesterday was sufficient so I didn't realize I would still need to trigger bors. |
My message should have triggered bors, I'm not sure what went wrong. |
@bors rollup |
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#131081 (Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`) - rust-lang#132577 (Report the `unexpected_cfgs` lint in external macros) - rust-lang#133023 (Merge `-Zhir-stats` into `-Zinput-stats`) - rust-lang#133200 (ignore an occasionally-failing test in Miri) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#131081 (Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`) - rust-lang#132577 (Report the `unexpected_cfgs` lint in external macros) - rust-lang#133023 (Merge `-Zhir-stats` into `-Zinput-stats`) - rust-lang#133200 (ignore an occasionally-failing test in Miri) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133023 - samestep:hir-stats-total-count, r=nnethercote Merge `-Zhir-stats` into `-Zinput-stats` Currently `-Z hir-stats` prints the size and count of various kinds of nodes, and the total size of all the nodes it counted, but not the total count of nodes. So, before this PR: ``` $ git clone https://github.com/BurntSushi/ripgrep $ cd ripgrep $ cargo +nightly rustc -- -Z hir-stats ast-stats-1 PRE EXPANSION AST STATS ast-stats-1 Name Accumulated Size Count Item Size ast-stats-1 ---------------------------------------------------------------- ast-stats-1 ... ast-stats-1 ---------------------------------------------------------------- ast-stats-1 Total 93_576 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size ast-stats-2 ---------------------------------------------------------------- ast-stats-2 ... ast-stats-2 ---------------------------------------------------------------- ast-stats-2 Total 2_430_648 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- hir-stats ... hir-stats ---------------------------------------------------------------- hir-stats Total 3_678_512 hir-stats ``` For consistency, this PR adds a total for the count as well: ``` $ cargo +stage1 rustc -- -Z hir-stats ast-stats-1 PRE EXPANSION AST STATS ast-stats-1 Name Accumulated Size Count Item Size ast-stats-1 ---------------------------------------------------------------- ast-stats-1 ... ast-stats-1 ---------------------------------------------------------------- ast-stats-1 Total 93_576 1_877 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size ast-stats-2 ---------------------------------------------------------------- ast-stats-2 ... ast-stats-2 ---------------------------------------------------------------- ast-stats-2 Total 2_430_648 48_625 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- hir-stats ... hir-stats ---------------------------------------------------------------- hir-stats Total 3_678_512 73_418 hir-stats ``` I wasn't sure if I was supposed to update `tests/ui/stats/hir-stats.stderr` to reflect this. I ran it locally, thinking it would fail, but it didn't: ``` $ ./x test tests/ui/stats ... running 2 tests i. test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 17949 filtered out ``` Also: is there a reason `-Z hir-stats` and `-Z input-stats` both exist? The former seems like it should completely supercede the latter. But strangely, the two give very different numbers for node counts: ``` $ cargo +nightly rustc -- -Z input-stats ... Lines of code: 483 Pre-expansion node count: 2386 Post-expansion node count: 63844 ``` That's a 30% difference in this case. Is it intentional that these numbers are so different? I see comments for both saying that they are merely approximations and should not be expected to be correct: https://github.com/rust-lang/rust/blob/bd0826a4521a845f36cce1b00e1dd2918ba09e90/compiler/rustc_ast_passes/src/node_count.rs#L1 https://github.com/rust-lang/rust/blob/bd0826a4521a845f36cce1b00e1dd2918ba09e90/compiler/rustc_passes/src/hir_stats.rs#L1-L3
Currently
-Z hir-stats
prints the size and count of various kinds of nodes, and the total size of all the nodes it counted, but not the total count of nodes. So, before this PR:For consistency, this PR adds a total for the count as well:
I wasn't sure if I was supposed to update
tests/ui/stats/hir-stats.stderr
to reflect this. I ran it locally, thinking it would fail, but it didn't:Also: is there a reason
-Z hir-stats
and-Z input-stats
both exist? The former seems like it should completely supercede the latter. But strangely, the two give very different numbers for node counts:That's a 30% difference in this case. Is it intentional that these numbers are so different? I see comments for both saying that they are merely approximations and should not be expected to be correct:
rust/compiler/rustc_ast_passes/src/node_count.rs
Line 1 in bd0826a
rust/compiler/rustc_passes/src/hir_stats.rs
Lines 1 to 3 in bd0826a