Skip to content

Deduplicate target and host filesearch - #160451

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Kobzol:lookup-opt
Aug 4, 2026
Merged

Deduplicate target and host filesearch#160451
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Kobzol:lookup-opt

Conversation

@Kobzol

@Kobzol Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member

I was looking into preprocessing the search directories somehow, so that both host and target don't have to scan them. However, it would be a bit annoying, because they don't share the tlib path. But then I noticed that the code already used Arc for SearchPath, which was essentially the same optimization, which made sense before #158823. But after that PR, it doesn't make sense to put SearchPath into Arc, because it doesn't really do anything, and the complex logic moved into FileSearch. So this PR puts that under Arc, to avoid doing duplicated work in the common case, where host == target.

r? petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 3, 2026
@Kobzol

Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 3, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
Deduplicate target and host filesearch
@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 781ece7 (781ece7ab29e668932aeede40eab8cfc7587d375)
Base parent: 7c329d6 (7c329d6c76e11ca40c5673818ab0439c1be8962c)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (781ece7): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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)
- - 0
Regressions ❌
(secondary)
0.4% [0.1%, 1.0%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-1.4%, -0.4%] 11
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -1.8%, secondary -1.2%)

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)
3.7% [0.7%, 6.7%] 2
Improvements ✅
(primary)
-1.8% [-4.1%, -0.4%] 3
Improvements ✅
(secondary)
-1.8% [-5.7%, -0.4%] 16
All ❌✅ (primary) -1.8% [-4.1%, -0.4%] 3

Cycles

Results (primary -0.3%, secondary 5.7%)

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

mean range count
Regressions ❌
(primary)
0.6% [0.4%, 0.8%] 6
Regressions ❌
(secondary)
8.2% [0.4%, 19.8%] 20
Improvements ✅
(primary)
-1.1% [-2.5%, -0.4%] 7
Improvements ✅
(secondary)
-1.4% [-3.2%, -0.4%] 7
All ❌✅ (primary) -0.3% [-2.5%, 0.8%] 13

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 491.018s -> 489.298s (-0.35%)
Artifact size: 390.29 MiB -> 390.23 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 3, 2026
Arc::new(SearchPath::from_sysroot_and_triple(sopts.sysroot.path(), target_triple))
};
let host_tlib_path = SearchPath::from_sysroot_and_triple(sopts.sysroot.path(), host_triple);
let target_tlib_path = SearchPath::from_sysroot_and_triple(sopts.sysroot.path(), target_triple);

@petrochenkov petrochenkov Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: cloning SearchPath is still cheaper than calling SearchPath::from_sysroot_and_triple for the second time, even without the Arc, but the benefit may be so small that it doesn't matter.
I'll leave it to you whether to restore this optimization or not.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked what it does and it seems to be very little work, so I think that complicating it with an Arc no longer makes sense.

@petrochenkov petrochenkov Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I meant without adding an Arc, literally let host_tlib_path = target_tlib_path.clone().)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Well, it would still need the check for host == target, I don't think it's needed here.

@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after addressing or not addressing #160451 (comment).
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 4, 2026
@Kobzol

Kobzol commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

I think it's not worth it to use Arc there anymore. Thanks for the review!

@bors r=petrochenkov rollup=iffy

Setting to iffy because of how our current PR queue looks like.

@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f0d1057 has been approved by petrochenkov

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

Reason for tree closure: manually handling queue due to backlog

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
…uwer

Rollup of 10 perf-sensitive pull requests

Successful merges:

 - #157281 (perf: skip irrelevant foreign impls when building the specialization graph)
 - #159403 (Next steps for FnDef binder changes (instantiate most FnDef binders))
 - #159763 (Optimize crate resolution for large workspace)
 - #160033 (Speed up `EverInitializedPlaces`)
 - #160268 (perf: store the fulfillment engine inline in ObligationCtxt)
 - #160317 (perf: Cache already-checked types in the privacy visitor)
 - #160399 (interpret: skip deref-projection validity checks when they are not needed)
 - #160451 (Deduplicate target and host filesearch)
 - #160453 (Add fast path to `escape_string_symbol`)
 - #160454 (Add offload guard flags to typeck to prevent perf regressions)
@rust-bors
rust-bors Bot merged commit 24c22c5 into rust-lang:main Aug 4, 2026
14 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 4, 2026
rust-timer added a commit that referenced this pull request Aug 4, 2026
Rollup merge of #160451 - Kobzol:lookup-opt, r=petrochenkov

Deduplicate target and host filesearch

I was looking into preprocessing the search directories somehow, so that both host and target don't have to scan them. However, it would be a bit annoying, because they don't share the tlib path. But then I noticed that the code already used `Arc` for `SearchPath`, which was essentially the same optimization, which made sense before #158823. But after that PR, it doesn't make sense to put `SearchPath` into `Arc`, because it doesn't really do anything, and the complex logic moved into `FileSearch`. So this PR puts that under `Arc`, to avoid doing duplicated work in the common case, where `host == target`.

r? petrochenkov
@Kobzol
Kobzol deleted the lookup-opt branch August 4, 2026 16:39
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

Verifying that actual perf results after merge match expected results
@rust-timer build 68be5aa

@rust-timer

This comment has been minimized.

WhySoBad pushed a commit to WhySoBad/miri that referenced this pull request Aug 5, 2026
…uwer

Rollup of 10 perf-sensitive pull requests

Successful merges:

 - rust-lang/rust#157281 (perf: skip irrelevant foreign impls when building the specialization graph)
 - rust-lang/rust#159403 (Next steps for FnDef binder changes (instantiate most FnDef binders))
 - rust-lang/rust#159763 (Optimize crate resolution for large workspace)
 - rust-lang/rust#160033 (Speed up `EverInitializedPlaces`)
 - rust-lang/rust#160268 (perf: store the fulfillment engine inline in ObligationCtxt)
 - rust-lang/rust#160317 (perf: Cache already-checked types in the privacy visitor)
 - rust-lang/rust#160399 (interpret: skip deref-projection validity checks when they are not needed)
 - rust-lang/rust#160451 (Deduplicate target and host filesearch)
 - rust-lang/rust#160453 (Add fast path to `escape_string_symbol`)
 - rust-lang/rust#160454 (Add offload guard flags to typeck to prevent perf regressions)
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (68be5aa): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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)
- - 0
Regressions ❌
(secondary)
0.4% [0.1%, 1.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-1.4%, -0.3%] 11
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.5%, secondary -0.2%)

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

mean range count
Regressions ❌
(primary)
0.5% [0.4%, 0.6%] 4
Regressions ❌
(secondary)
1.8% [0.5%, 7.1%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-5.2%, -2.1%] 3
All ❌✅ (primary) 0.5% [0.4%, 0.6%] 4

Cycles

Results (primary 0.1%, secondary -0.2%)

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

mean range count
Regressions ❌
(primary)
0.8% [0.6%, 1.1%] 7
Regressions ❌
(secondary)
4.0% [0.6%, 13.9%] 4
Improvements ✅
(primary)
-0.8% [-1.2%, -0.4%] 5
Improvements ✅
(secondary)
-1.8% [-4.4%, -0.4%] 10
All ❌✅ (primary) 0.1% [-1.2%, 1.1%] 12

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.577s -> 490.03s (0.09%)
Artifact size: 390.24 MiB -> 390.29 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants