Move std::io::Error into core#155625
Conversation
This comment has been minimized.
This comment has been minimized.
b86f41f to
c538e5d
Compare
This comment has been minimized.
This comment has been minimized.
6c37f53 to
65d4011
Compare
This comment has been minimized.
This comment has been minimized.
65d4011 to
56a8e8c
Compare
93b1fa3 to
d3835aa
Compare
This comment has been minimized.
This comment has been minimized.
|
example of how to link from |
d3835aa to
8bfceb6
Compare
That's a clever trick I never knew about! Looks like it's also required for linking to incoherent implementations even within the file that creates them too. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8bfceb6 to
96864eb
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
96864eb to
7cad458
Compare
This comment has been minimized.
This comment has been minimized.
maybe just leave it until you get the PR to work, that way there's less comment spam. |
|
I invite anyone with more experience interpreting a perf run to help me out here, but below is my best attempt at understanding these results. From what I can tell, there is no measurable difference in runtime performance, despite the following two changes which could impact runtime:
However it's possible runtime performance along codepaths affected by this PR isn't being measured by the current set of benchmarks. After all, the worst performance is likely to be seen in dropping Out of the primary compilation benchmarks, it appears the worst regressions come down to spending more time in LLVM optimising, or more time in @rustbot label: +perf-regression-triaged |
e11e4f4 to
f553a2c
Compare
|
Since there is a measurable performance difference in compilation time, I've split this PR's commits further to hopefully make it easier to review. |
Viewing internals wont be possible from `std` once moved into `core`.
Adjust `Error` documentation `core` is more restrictive with documentation quality and linking to other items. Methods that will be implemented through incoherence must also be explicitly linked.
Personal preference that will be used for another module in a later commit. Purely stylistic.
They'll be moved into `core` but must be accessible from `std`.
Incoherence is required to define inherit methods on `Error` from `alloc` and `std` once it is moved into `core`. This is required because: 1. `Box` is part of `Error`'s public API and that is only accessible from `alloc`. 2. `RawOsError` methods must ensure the `OsFunctions` atomic pointer is appropriately set, which can only be done from `std`.
Required to allow `std` access from `core`
This allows `Error` to be moved into `core` while still retaining the ability to store custom error data. This may have performance implications!
Stored in a `static` `AtomicPtr` to allow definition in `core` and setting in `std`. Should be replaced with Externally Implemented Items (EII) or similar once stable.
f553a2c to
5fff01b
Compare
This comment has been minimized.
This comment has been minimized.
| #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] | ||
| pub use self::os_functions::{decode_error_kind, format_os_error, is_interrupted, set_functions}; | ||
| use crate::{error, fmt}; | ||
|
|
There was a problem hiding this comment.
Maybe split this commit out first and testing(merge it first) it if have performance regression?
I think this commit have maximal possibility have performance issue.
There was a problem hiding this comment.
It's tricky because both these changes are purely a negative until Error is moved into core, so it's hard to justify splitting them out.
5fff01b to
d1ecdab
Compare
This comment has been minimized.
This comment has been minimized.
d1ecdab to
55b632f
Compare
This comment has been minimized.
This comment has been minimized.
Now that `Error` lives in `core::io`, doc links to it from `core` can be simplified.
55b632f to
7c41c8e
Compare
Move `IoSlice` and `IoSliceMut` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Related: #152918 Related: #155625 ## Description Moves `std::io::IoSlice` and `std::io::IoSliceMut` into `core::io`. This is required for the `Read` and `Write` traits to be moved into `alloc` and/or `core`, as they contain stable methods which work with IO slices. Similar to #155574, this PR inlines the `std::sys` types required to create an ABI compatible type for the platforms where such compatibility is guaranteed. Additionally, I've moved the relevant tests out of `std::io::tests` into `coretests::io::io_slice`. --- ## Notes * This PR overlaps with #152918, but goes further than moving the IO slice types to `alloc` and instead moves them straight to `core`. Since these types have no interaction with allocation, and doing so will allow `Write` to move to `core::io`, I consider this a better home for these types. * Some discussion around the decision to not use a `core::sys` module can be found [here](#155574 (comment)). * I've renamed `unsupported` to `generic` to better reflect that `IoSlice(Mut)` _is_ supported by all platforms, it just doesn't have a special ABI-compatible type. I don't want to imply that parts of `core` "don't work" depending on the target; `IoSlice(Mut)` works exactly as expected on all targets. * I've made `pub` items within each platform-specific representation `pub(super)` to highlight that everything within `core::io::io_slice` is an internal implementation detail not meant for any other part of the crate to be aware of. * No AI tooling of any kind was used during the creation of this PR.
Move `IoSlice` and `IoSliceMut` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Related: #152918 Related: #155625 ## Description Moves `std::io::IoSlice` and `std::io::IoSliceMut` into `core::io`. This is required for the `Read` and `Write` traits to be moved into `alloc` and/or `core`, as they contain stable methods which work with IO slices. Similar to #155574, this PR inlines the `std::sys` types required to create an ABI compatible type for the platforms where such compatibility is guaranteed. Additionally, I've moved the relevant tests out of `std::io::tests` into `coretests::io::io_slice`. --- ## Notes * This PR overlaps with #152918, but goes further than moving the IO slice types to `alloc` and instead moves them straight to `core`. Since these types have no interaction with allocation, and doing so will allow `Write` to move to `core::io`, I consider this a better home for these types. * Some discussion around the decision to not use a `core::sys` module can be found [here](#155574 (comment)). * I've renamed `unsupported` to `generic` to better reflect that `IoSlice(Mut)` _is_ supported by all platforms, it just doesn't have a special ABI-compatible type. I don't want to imply that parts of `core` "don't work" depending on the target; `IoSlice(Mut)` works exactly as expected on all targets. * I've made `pub` items within each platform-specific representation `pub(super)` to highlight that everything within `core::io::io_slice` is an internal implementation detail not meant for any other part of the crate to be aware of. * No AI tooling of any kind was used during the creation of this PR.
Move `IoSlice` and `IoSliceMut` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Related: #152918 Related: #155625 ## Description Moves `std::io::IoSlice` and `std::io::IoSliceMut` into `core::io`. This is required for the `Read` and `Write` traits to be moved into `alloc` and/or `core`, as they contain stable methods which work with IO slices. Similar to #155574, this PR inlines the `std::sys` types required to create an ABI compatible type for the platforms where such compatibility is guaranteed. Additionally, I've moved the relevant tests out of `std::io::tests` into `coretests::io::io_slice`. --- ## Notes * This PR overlaps with #152918, but goes further than moving the IO slice types to `alloc` and instead moves them straight to `core`. Since these types have no interaction with allocation, and doing so will allow `Write` to move to `core::io`, I consider this a better home for these types. * Some discussion around the decision to not use a `core::sys` module can be found [here](#155574 (comment)). * I've renamed `unsupported` to `generic` to better reflect that `IoSlice(Mut)` _is_ supported by all platforms, it just doesn't have a special ABI-compatible type. I don't want to imply that parts of `core` "don't work" depending on the target; `IoSlice(Mut)` works exactly as expected on all targets. * I've made `pub` items within each platform-specific representation `pub(super)` to highlight that everything within `core::io::io_slice` is an internal implementation detail not meant for any other part of the crate to be aware of. * No AI tooling of any kind was used during the creation of this PR.
Move `IoSlice` and `IoSliceMut` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Related: #152918 Related: #155625 ## Description Moves `std::io::IoSlice` and `std::io::IoSliceMut` into `core::io`. This is required for the `Read` and `Write` traits to be moved into `alloc` and/or `core`, as they contain stable methods which work with IO slices. Similar to #155574, this PR inlines the `std::sys` types required to create an ABI compatible type for the platforms where such compatibility is guaranteed. Additionally, I've moved the relevant tests out of `std::io::tests` into `coretests::io::io_slice`. --- ## Notes * This PR overlaps with #152918, but goes further than moving the IO slice types to `alloc` and instead moves them straight to `core`. Since these types have no interaction with allocation, and doing so will allow `Write` to move to `core::io`, I consider this a better home for these types. * Some discussion around the decision to not use a `core::sys` module can be found [here](#155574 (comment)). * I've renamed `unsupported` to `generic` to better reflect that `IoSlice(Mut)` _is_ supported by all platforms, it just doesn't have a special ABI-compatible type. I don't want to imply that parts of `core` "don't work" depending on the target; `IoSlice(Mut)` works exactly as expected on all targets. * I've made `pub` items within each platform-specific representation `pub(super)` to highlight that everything within `core::io::io_slice` is an internal implementation detail not meant for any other part of the crate to be aware of. * No AI tooling of any kind was used during the creation of this PR.
|
☔ The latest upstream changes (presumably #155849) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
ACP: rust-lang/libs-team#755
Tracking issue: #154046
Related: #155574
Related: #152918
Description
Moves
std::io::Errorintocore, deferringBox-adjacent methods to incoherent implementations inalloc, andRawOsErrormethods tostd. This requires some substantial changes to the internals ofError, but none of them are breaking changes or externally visible.Notably, I've replaced usage of
Boxwith a wrapper around a pointer and an appropriate drop function. This requires the addition of quite a few lines of unsafe, but is required to work aroundBoxonly being accessible fromalloc. Additionally, an atomic pointer to a VTable is used for working withRawOsErrorincore, since we cannot know the required implementations withoutstd.Notes
std::iotoalloc#152918std::io::RawOsErrortocore::io#155574