Skip to content

Deduplicate -L search paths #145408

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

Merged
merged 2 commits into from
Aug 15, 2025
Merged

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Aug 14, 2025

For each -L passed to the compiler, we eagerly scan the whole directory. If it has a lot of files, that results in a lot of allocations. So it's needless to do this if some -L paths are actually duplicated (which can happen e.g. in the situation in the linked issue).

This PR both deduplicates the args, and also teaches rustdoc not to pass duplicated args to merged doctests.

Fixes: #145375

@rustbot
Copy link
Collaborator

rustbot commented Aug 14, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 14, 2025
@Kobzol Kobzol force-pushed the deduplicate-search-paths branch from e17ef7d to fd5b737 Compare August 14, 2025 20:38
@Kobzol
Copy link
Member Author

Kobzol commented Aug 14, 2025

r? @petrochenkov

@rustbot rustbot assigned petrochenkov and unassigned BoxyUwU Aug 14, 2025
let search_paths: Vec<SearchPath> = {
let mut seen_search_paths = FxHashSet::default();
let search_path_matches: Vec<String> = matches.opt_strs("L");
search_path_matches
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
search_path_matches
matches.opt_strs("L")

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't work without the local variable, because the filter passes through references, and they would become dangling if the data wasn't stored on stack.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 15, 2025

📌 Commit fd5b737 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2025
@Kobzol
Copy link
Member Author

Kobzol commented Aug 15, 2025

I'll also run a parallel perf. run just to see if there is any effect in the perf. suite (I would say unlikely).

@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 Aug 15, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 15, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 15, 2025

☀️ Try build successful (CI)
Build commit: e175e89 (e175e89f4816b2cb240147ceda17204e844ec589, parent: ba412a6e70ac84641be7764d088acabd0eb3fa39)

@rust-timer

This comment has been minimized.

bors added a commit that referenced this pull request Aug 15, 2025
Rollup of 11 pull requests

Successful merges:

 - #144210 (std: thread: Return error if setting thread stack size fails)
 - #145310 (Reduce usage of `compiler_for` in bootstrap)
 - #145311 (ci: clean windows disk space in background)
 - #145340 (Split codegen backend check step into two and don't run it with `x check compiler`)
 - #145408 (Deduplicate -L search paths)
 - #145412 (Windows: Replace `GetThreadId`+`GetCurrentThread` with `GetCurrentThreadId`)
 - #145413 (bootstrap: Reduce dependencies)
 - #145426 (Fix typos in bootstrap.example.toml)
 - #145430 (Fix wrong spans with external macros in the `dropping_copy_types` lint)
 - #145431 (Enhance UI test output handling for runtime errors)
 - #145448 (Autolabel `src/tools/{rustfmt,rust-analyzer}` changes with `T-{rustfmt,rust-analyzer}`)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e175e89): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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)
- - 0
Regressions ❌
(secondary)
1.8% [1.8%, 1.8%] 2
Improvements ✅
(primary)
-0.9% [-7.4%, -0.2%] 10
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 21
All ❌✅ (primary) -0.9% [-7.4%, -0.2%] 10

Max RSS (memory usage)

Results (primary 6.7%, secondary 3.2%)

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

mean range count
Regressions ❌
(primary)
14.1% [14.1%, 14.1%] 1
Regressions ❌
(secondary)
3.2% [3.2%, 3.2%] 1
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 6.7% [-0.7%, 14.1%] 2

Cycles

Results (primary -6.7%, secondary -1.3%)

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.9% [3.9%, 3.9%] 1
Improvements ✅
(primary)
-6.7% [-6.7%, -6.7%] 1
Improvements ✅
(secondary)
-3.9% [-5.3%, -2.6%] 2
All ❌✅ (primary) -6.7% [-6.7%, -6.7%] 1

Binary size

Results (primary -0.7%, secondary -0.4%)

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.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 3
Improvements ✅
(secondary)
-0.4% [-0.8%, -0.1%] 6
All ❌✅ (primary) -0.7% [-0.7%, -0.7%] 3

Bootstrap: 471.246s -> 469.118s (-0.45%)
Artifact size: 377.51 MiB -> 377.39 MiB (-0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 15, 2025
@Kobzol
Copy link
Member Author

Kobzol commented Aug 15, 2025

Ok clap_derive is noise, but the bootstrap improvements look nice!

@bors bors merged commit 30c967d into rust-lang:master Aug 15, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 15, 2025
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145408 - Kobzol:deduplicate-search-paths, r=petrochenkov

Deduplicate -L search paths

For each -L passed to the compiler, we eagerly scan the whole directory. If it has a lot of files, that results in a lot of allocations. So it's needless to do this if some -L paths are actually duplicated (which can happen e.g. in the situation in the linked issue).

This PR both deduplicates the args, and also teaches rustdoc not to pass duplicated args to merged doctests.

Fixes: #145375
@Kobzol Kobzol deleted the deduplicate-search-paths branch August 15, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doctest slowdown with large target directory
6 participants