Skip to content

perf(compilation): Directly construct Take and Chain#156680

Closed
bushrat011899 wants to merge 1 commit into
rust-lang:mainfrom
bushrat011899:core_io_util_no_new_inline
Closed

perf(compilation): Directly construct Take and Chain#156680
bushrat011899 wants to merge 1 commit into
rust-lang:mainfrom
bushrat011899:core_io_util_no_new_inline

Conversation

@bushrat011899
Copy link
Copy Markdown
Contributor

Objective

Performance regression in compilation discovered found here was narrowed down to the movement of utility types from std::io to core::io here. Likely culprit is the introduction of core::io::take and core::io::chain to construction Take and Chain within Read::take and Read::chain. If this does not address the compilation difference, then it must be the unchanged methods which are not #[inline], such as Chain::into_inner, etc.

Have not replicated the compilation performance difference locally, happy to amend/delete this PR if a perf-run shows it has no effect.,


Notes

  • No AI tooling of any kind was used during the creation of this PR.

Moving `Take` and `Chain` from `std::io` into `core::io` required setting up constructors for use in
`std`. These constructors increased compilation time in `image` by 1.4% due to increased time spent
in LTO. Switching to unstable public fields for consturction instead.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 17, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 17, 2026

r? @scottmcm

rustbot has assigned @scottmcm.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, scottmcm

@lqd
Copy link
Copy Markdown
Member

lqd commented May 18, 2026

@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 May 18, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 18, 2026
…try>

perf(compilation): Directly construct `Take` and `Chain`
@scottmcm
Copy link
Copy Markdown
Member

I'm leaving libs reviews.
@rustbot reroll

@rustbot rustbot assigned Mark-Simulacrum and unassigned scottmcm May 18, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 18, 2026

☀️ Try build successful (CI)
Build commit: d6321e3 (d6321e37d7da8ed036012cfd642e17747ffc50f2, parent: a31c27a887b40df16ab9dfb8c9f7924636092509)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d6321e3): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@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.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -3.6%)

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)
- - 0
Improvements ✅
(secondary)
-3.6% [-4.7%, -2.4%] 3
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.8%, secondary 3.6%)

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

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
3.6% [3.6%, 3.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [2.8%, 2.8%] 1

Binary size

Results (secondary -0.1%)

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)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) - - 0

Bootstrap: 510.693s -> 511.061s (0.07%)
Artifact size: 400.56 MiB -> 402.57 MiB (0.50%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 18, 2026
@bushrat011899
Copy link
Copy Markdown
Contributor Author

Very interesting, the performance results imply the regression in compilation time comes from the methods which were not modified by my PR, only moved from std to core. Since that's the case, I'm closing this PR.

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library 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