Skip to content

Add secondary stress benchmark for adding trait in owner's trait_map#2436

Closed
aerooneqq wants to merge 1 commit into
rust-lang:masterfrom
aerooneqq:add-trait-incr-patches
Closed

Add secondary stress benchmark for adding trait in owner's trait_map#2436
aerooneqq wants to merge 1 commit into
rust-lang:masterfrom
aerooneqq:add-trait-incr-patches

Conversation

@aerooneqq
Copy link
Copy Markdown

This PR adds a new secondary benchmark for case when a new trait is added to in_scope_traits_map query. During experiments with queries in #155678 (where I merged some queries into one, meaning invalidation of any part of the query will invalidate whole new merged query) improvements were reported, however I did not find any benchmark that covered case when a new trait is added to in_scope_traits_map query, so I can not fully trust those results.

A real-life scenario where such regression is possible is importing (or creating) a new trait with functions whose names are mentioned frequently in a file in a deferred typecheck context.

cc @petrochenkov

@aerooneqq aerooneqq force-pushed the add-trait-incr-patches branch from 5c25208 to 569c00d Compare April 28, 2026 12:48
@Kobzol
Copy link
Copy Markdown
Member

Kobzol commented Apr 29, 2026

Looks simple enough, and should be fast to build. @nnethercote Any concerns?

@petrochenkov
Copy link
Copy Markdown

I think if rust-lang/rust#155678 makes the new benchmark red in the incr-changed scenario, we should still merge it.

Code changes between two incremental builds do not typically include adding a trait (import) with specific item name.
Sure it can happen occasionally, traits are indeed added sometimes, but if 1 out of 100 incremental rebuilds becomes slower that's probably not a big deal.

@nnethercote
Copy link
Copy Markdown
Contributor

Code changes between two incremental builds do not typically include adding a trait (import) with specific item name. Sure it can happen occasionally, traits are indeed added sometimes, but if 1 out of 100 incremental rebuilds becomes slower that's probably not a big deal.

Yes, adding traits does seem like a rare scenario so I don't feel the need to for a benchmark to test it. I won't block it if someone else is strongly in favour, but it seems fairly low value.

@aerooneqq
Copy link
Copy Markdown
Author

aerooneqq commented May 1, 2026

I think if rust-lang/rust#155678 makes the new benchmark red in the incr-changed scenario, we should still merge it.

On my laptop it shows the following numbers (with regressions in incr-patched scenario). But they are not as big as it was in first perf run.
Screenshot from 2026-05-01 10-21-44

@aerooneqq aerooneqq force-pushed the add-trait-incr-patches branch from 569c00d to bb82f70 Compare May 12, 2026 07:13
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request May 27, 2026
Merge several HIR-level queries into one



Now four queries (`local_def_id_to_hir_id`, `opt_hir_owner_nodes`, `opt_ast_lowering_delayed_lints`, `in_scope_traits_map`) were replaced with regular methods which acts like getters. 
An `hir_owner` query was added that returns a `ProjectedMaybeOwner` that contains all those fields. `hir_attr_map` remains a separate query as adding attributes to `ProjectedMaybeOwner` led to [perf regressions](#155678 (comment)). 
There is a similar issue with `in_scopes_trait_map`, but according to the comments from rust-lang/rustc-perf#2436 it is a rare case.
Most of the changes in incremental tests are renames from `opt_hir_owner_nodes` -> `hir_owner`, but there are few cases when new dirty queries were added.

r? @petrochenkov
r? @oli-obk
@aerooneqq
Copy link
Copy Markdown
Author

Closing as #155678 is merged.

@aerooneqq aerooneqq closed this May 28, 2026
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request May 28, 2026
Merge several HIR-level queries into one



Now four queries (`local_def_id_to_hir_id`, `opt_hir_owner_nodes`, `opt_ast_lowering_delayed_lints`, `in_scope_traits_map`) were replaced with regular methods which acts like getters. 
An `hir_owner` query was added that returns a `ProjectedMaybeOwner` that contains all those fields. `hir_attr_map` remains a separate query as adding attributes to `ProjectedMaybeOwner` led to [perf regressions](rust-lang/rust#155678 (comment)). 
There is a similar issue with `in_scopes_trait_map`, but according to the comments from rust-lang/rustc-perf#2436 it is a rare case.
Most of the changes in incremental tests are renames from `opt_hir_owner_nodes` -> `hir_owner`, but there are few cases when new dirty queries were added.

r? @petrochenkov
r? @oli-obk
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request May 30, 2026
Merge several HIR-level queries into one



Now four queries (`local_def_id_to_hir_id`, `opt_hir_owner_nodes`, `opt_ast_lowering_delayed_lints`, `in_scope_traits_map`) were replaced with regular methods which acts like getters. 
An `hir_owner` query was added that returns a `ProjectedMaybeOwner` that contains all those fields. `hir_attr_map` remains a separate query as adding attributes to `ProjectedMaybeOwner` led to [perf regressions](rust-lang/rust#155678 (comment)). 
There is a similar issue with `in_scopes_trait_map`, but according to the comments from rust-lang/rustc-perf#2436 it is a rare case.
Most of the changes in incremental tests are renames from `opt_hir_owner_nodes` -> `hir_owner`, but there are few cases when new dirty queries were added.

r? @petrochenkov
r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants