Skip to content

Conversation

@azhogin
Copy link
Contributor

@azhogin azhogin commented Oct 1, 2025

intrinsic_raw query works like inlined function for non-incremental build and non-local DefId.

Optimization may be profitable for queries with low normalized average execution time (to replace cache lookup into inlined call) and be significant with good cache_hits.

Query cache_hits min_ns max_ns avg_ns_norm
source_span 11361 18 2991 66
hir_owner_parent 5773 52 1773 163
is_doc_hidden 3134 47 1111 285
lookup_deprecation_entry 13905 36 6208 287
object_lifetime_default 5840 63 4688 290
upvars_mentioned 2575 75 7722 322
*intrinsic_raw* 21235 73 3453 367

Draft PR to measure performance changes.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 1, 2025
@azhogin azhogin force-pushed the azhogin/intrinsic-query-opt branch from df2f166 to 8c34776 Compare October 1, 2025 16:19
@rust-log-analyzer

This comment has been minimized.

@azhogin azhogin force-pushed the azhogin/intrinsic-query-opt branch from 8c34776 to 5b1d160 Compare October 1, 2025 17:41
@azhogin
Copy link
Contributor Author

azhogin commented Oct 1, 2025

@petrochenkov, this is continuation of #146880.
intrinsic_raw query changed to inlined function in case of non-incremental build.
Could you, pls, run performance tests for this PR?

@lqd
Copy link
Member

lqd commented Oct 1, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 1, 2025
intrinsic_raw query optimization attempt using inlined functions
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 1, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 1, 2025

☀️ Try build successful (CI)
Build commit: c329581 (c329581003926522a52e72cbdee730b4ef6deef0, parent: d4ae855111df8c7ee255bea4c112e74b7d72cf45)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c329581): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
0.8% [0.3%, 1.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.2%] 4
All ❌✅ (primary) 1.4% [1.4%, 1.4%] 1

Max RSS (memory usage)

Results (primary -5.7%, secondary 1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.7% [1.3%, 2.0%] 3
Improvements ✅
(primary)
-5.7% [-5.7%, -5.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -5.7% [-5.7%, -5.7%] 1

Cycles

Results (primary -2.5%, secondary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
-2.7% [-3.3%, -2.0%] 2
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 470.999s -> 470.199s (-0.17%)
Artifact size: 387.75 MiB -> 387.77 MiB (0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 2, 2025
@petrochenkov petrochenkov self-assigned this Oct 2, 2025
@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 2, 2025
@petrochenkov
Copy link
Contributor

  • Adding a dependency on rustc_metadata to everything isn't right, it would have to use a hook to be merged, but it's ok for benchmarking.
  • The choice of query (intrinsic_raw) was done based on some statistics, but it doesn't pass an eye test, both local and extern versions of the provider function look more expensive that a synchronized map (query cache) lookup.
  • The perf results are noise anyway.

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2025
@azhogin azhogin changed the title intrinsic_raw query optimization attempt using inlined functions intrinsic_raw query optimization attempt Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants