Move std::io::copy to alloc::io - #158548
Conversation
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rustbot blocked |
This comment has been minimized.
This comment has been minimized.
1bcdfe1 to
43f67ba
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
90ec159 to
8139972
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8139972 to
cb62676
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cb62676 to
3bb0364
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3bb0364 to
df9a018
Compare
This comment has been minimized.
This comment has been minimized.
df9a018 to
8f363d9
Compare
This comment has been minimized.
This comment has been minimized.
8f363d9 to
d331e98
Compare
174d318 to
a0ff5e6
Compare
|
LGTM minus the extra comment about |
Co-Authored-By: Clar Fon <15850505+clarfonthey@users.noreply.github.com>
a0ff5e6 to
a8ef638
Compare
|
@bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Move `std::io::copy` to `alloc::io`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (a168732): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.5%, secondary 0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.2%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 490.618s -> 492.892s (0.46%) |
|
Happy to see no downsides! The "improvement" is only the |
|
@bors r+ rollup Hooray! |
…uwer Rollup of 8 pull requests Successful merges: - #160262 (Library lock file maintenance) - #158548 (Move `std::io::copy` to `alloc::io`) - #158814 (Produce an error when `#[inline]` and `#[rust_force_inline]` are used together) - #160025 (Fix an edge case with `StepBy::nth` on non-fused iterators) - #160271 (Resolver: Introduce `CmRef` which has a speclative borrow variant for `CmRefCell`) - #160281 (Fix(lib/fs/tests): Avoid permission denials when cleaning up TempDirs in `set_get_permissions_nofollows*`) - #160325 (tidy: Check `proc_macro_deps.rs` by reading it, not by including it) - #160334 (Add regression test for unused_allocation on boxed comparison)
Rollup merge of #158548 - bushrat011899:alloc_io_copy_internals, r=clarfonthey Move `std::io::copy` to `alloc::io` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Split From: #156527 ~~Blocked On: #158547 ## Description Moves `std::io::copy` into `alloc::io`. Blocked on #158547. This relies on specialization to allow `std` to provide optimised copy implementations for its types where appropriate. The exact technique involves defining a new trait, `alloc::io::SpecCopy`: ```rust #[doc(hidden)] #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] #[rustc_specialization_trait] pub trait SpecCopy: Read { /// Attempt to copy from this reader to the provided writer using a specialized /// process. fn copy<R: Read + ?Sized, W: Write + ?Sized>( _reader: &mut R, _writer: &mut W, ) -> Result<CopyState>; } ``` Since optimised copying requires both the reader and writer to support the operation between each other, we can choose one of them to be the implementer of the copy algorithm, and delegate specialization to it. In this case, I've chosen the reader to be the provider of the specialized copy implementation arbitrarily. Note that the `SpecCopy::copy` function is generic over the reader specifically to allow wrappers like `Take<R>` to be visible to the implementation of `copy`. Because this introduces a new layer of specialization to `io::copy`, I think this PR should be benchmarked to make sure performance characteristics aren't too different. I am expecting compilation time to be slightly worse, since there's just more specialization happening, but the actual code run _should_ be the same. --- ## Notes * No AI tooling of any kind was used during the creation of this PR. * Please see #154046 (comment) for a review order and broader context for this PR.
…r=clarfonthey Move `std::io` tests to `alloctests` & add prelude ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 ~~Blocked on: rust-lang#158548~~ ## Description * Moves tests out of `std::io` into `alloctests` now that the relevant items are fully available from `alloc::io`. * Adds documentation to `alloc::io` * Adds prelude modules to `core::io` and `alloc::io`. --- ## Notes * No AI tooling of any kind was used during the creation of this PR.
…r=clarfonthey Move `std::io` tests to `alloctests` & add prelude ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 ~~Blocked on: rust-lang#158548~~ ## Description * Moves tests out of `std::io` into `alloctests` now that the relevant items are fully available from `alloc::io`. * Adds documentation to `alloc::io` * Adds prelude modules to `core::io` and `alloc::io`. --- ## Notes * No AI tooling of any kind was used during the creation of this PR.
…r=clarfonthey Move `std::io` tests to `alloctests` & add prelude ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 ~~Blocked on: rust-lang#158548~~ ## Description * Moves tests out of `std::io` into `alloctests` now that the relevant items are fully available from `alloc::io`. * Adds documentation to `alloc::io` * Adds prelude modules to `core::io` and `alloc::io`. --- ## Notes * No AI tooling of any kind was used during the creation of this PR.
…r=clarfonthey Move `std::io` tests to `alloctests` & add prelude ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 ~~Blocked on: rust-lang#158548~~ ## Description * Moves tests out of `std::io` into `alloctests` now that the relevant items are fully available from `alloc::io`. * Adds documentation to `alloc::io` * Adds prelude modules to `core::io` and `alloc::io`. --- ## Notes * No AI tooling of any kind was used during the creation of this PR.
Rollup merge of #156527 - bushrat011899:core_io_test_merge, r=clarfonthey Move `std::io` tests to `alloctests` & add prelude ACP: rust-lang/libs-team#755 Tracking issue: #154046 ~~Blocked on: #158548~~ ## Description * Moves tests out of `std::io` into `alloctests` now that the relevant items are fully available from `alloc::io`. * Adds documentation to `alloc::io` * Adds prelude modules to `core::io` and `alloc::io`. --- ## Notes * No AI tooling of any kind was used during the creation of this PR.
View all comments
ACP: rust-lang/libs-team#755
Tracking issue: #154046
Split From: #156527
Blocked On: #158547Description
Moves
std::io::copyintoalloc::io. Blocked on #158547.This relies on specialization to allow
stdto provide optimised copy implementations for its types where appropriate. The exact technique involves defining a new trait,alloc::io::SpecCopy:Since optimised copying requires both the reader and writer to support the operation between each other, we can choose one of them to be the implementer of the copy algorithm, and delegate specialization to it. In this case, I've chosen the reader to be the provider of the specialized copy implementation arbitrarily. Note that the
SpecCopy::copyfunction is generic over the reader specifically to allow wrappers likeTake<R>to be visible to the implementation ofcopy.Because this introduces a new layer of specialization to
io::copy, I think this PR should be benchmarked to make sure performance characteristics aren't too different. I am expecting compilation time to be slightly worse, since there's just more specialization happening, but the actual code run should be the same.Notes
alloc::ioandcore::io#154046 (comment) for a review order and broader context for this PR.