Inline String::into_raw_parts and reuse from_utf16 optimization - #160536
Conversation
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
This seems reasonable to me. Thank you! @bors r+ rollup |
Rollup of 20 pull requests Successful merges: - #161259 (move some attribute related structs out of rustc_attr_ir) - #160853 (delegation: simplify matches on `FnKind`, minor refactorings) - #161161 (proc_macro: add support for 16-bit targets) - #159899 ( `GenericArgs::types` triage + possible fixes) - #160459 (Use attribute parser for `deprecated` attribute checking) - #160536 (Inline `String::into_raw_parts` and reuse `from_utf16` optimization) - #160563 (Make `BorrowedCursor<'a, T>` covariant in `'a` and drop an indirection) - #160595 (Clarify `str::split_at` docs) - #160813 (Optimize linked list iterator performance) - #161271 (doc: document safety requirements for core WTF-8) - #161317 (LLVM 24: configure float-abi via module flag) - #161320 (Only suggest `RUST_MIN_STACK` if maybe stack overflow) - #161369 (Add regression test for confusing lifetime error message issue) - #161393 (Configure LLM policy URL for triagebot) - #161403 (splat-fn-ptr-ptr-tuple.rs: add `let` to avoid UB) - #161409 (Add back `tests/rustdoc-gui/notable-trait.goml` test) - #161410 (Fix rustdoc remapping `documentation` scope documentation) - #161415 (Update expect messages in path docs to better follow guidelines) - #161438 (Change triagebot backport to ping T-libs-fcp) - #161442 (Add regression test for dead code on type alias used in impl self type) Failed merges: - #160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`)
Rollup merge of #160536 - fereidani:utf16_units, r=clarfonthey Inline `String::into_raw_parts` and reuse `from_utf16` optimization 1. I noticed that comment `// This isn't done via collect::<Result<_, _>>() for performance reasons.` explicitly states that this approach is wrong, but `from_utf16le` and `from_utf16be` are not using the same optimization. 2. I believe `into_raw_parts` is missing the `#[inline]` as any other similar functions in the standard library are marked either with `inline` or `inline(always)`. This is also related to #48994; whenever that fix lands, optimizing `from_utf16_units` will results in these 3 functions getting optimized.
Rollup of 20 pull requests Successful merges: - rust-lang/rust#161259 (move some attribute related structs out of rustc_attr_ir) - rust-lang/rust#160853 (delegation: simplify matches on `FnKind`, minor refactorings) - rust-lang/rust#161161 (proc_macro: add support for 16-bit targets) - rust-lang/rust#159899 ( `GenericArgs::types` triage + possible fixes) - rust-lang/rust#160459 (Use attribute parser for `deprecated` attribute checking) - rust-lang/rust#160536 (Inline `String::into_raw_parts` and reuse `from_utf16` optimization) - rust-lang/rust#160563 (Make `BorrowedCursor<'a, T>` covariant in `'a` and drop an indirection) - rust-lang/rust#160595 (Clarify `str::split_at` docs) - rust-lang/rust#160813 (Optimize linked list iterator performance) - rust-lang/rust#161271 (doc: document safety requirements for core WTF-8) - rust-lang/rust#161317 (LLVM 24: configure float-abi via module flag) - rust-lang/rust#161320 (Only suggest `RUST_MIN_STACK` if maybe stack overflow) - rust-lang/rust#161369 (Add regression test for confusing lifetime error message issue) - rust-lang/rust#161393 (Configure LLM policy URL for triagebot) - rust-lang/rust#161403 (splat-fn-ptr-ptr-tuple.rs: add `let` to avoid UB) - rust-lang/rust#161409 (Add back `tests/rustdoc-gui/notable-trait.goml` test) - rust-lang/rust#161410 (Fix rustdoc remapping `documentation` scope documentation) - rust-lang/rust#161415 (Update expect messages in path docs to better follow guidelines) - rust-lang/rust#161438 (Change triagebot backport to ping T-libs-fcp) - rust-lang/rust#161442 (Add regression test for dead code on type alias used in impl self type) Failed merges: - rust-lang/rust#160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`)
Rollup of 20 pull requests Successful merges: - rust-lang#161259 (move some attribute related structs out of rustc_attr_ir) - rust-lang#160853 (delegation: simplify matches on `FnKind`, minor refactorings) - rust-lang#161161 (proc_macro: add support for 16-bit targets) - rust-lang#159899 ( `GenericArgs::types` triage + possible fixes) - rust-lang#160459 (Use attribute parser for `deprecated` attribute checking) - rust-lang#160536 (Inline `String::into_raw_parts` and reuse `from_utf16` optimization) - rust-lang#160563 (Make `BorrowedCursor<'a, T>` covariant in `'a` and drop an indirection) - rust-lang#160595 (Clarify `str::split_at` docs) - rust-lang#160813 (Optimize linked list iterator performance) - rust-lang#161271 (doc: document safety requirements for core WTF-8) - rust-lang#161317 (LLVM 24: configure float-abi via module flag) - rust-lang#161320 (Only suggest `RUST_MIN_STACK` if maybe stack overflow) - rust-lang#161369 (Add regression test for confusing lifetime error message issue) - rust-lang#161393 (Configure LLM policy URL for triagebot) - rust-lang#161403 (splat-fn-ptr-ptr-tuple.rs: add `let` to avoid UB) - rust-lang#161409 (Add back `tests/rustdoc-gui/notable-trait.goml` test) - rust-lang#161410 (Fix rustdoc remapping `documentation` scope documentation) - rust-lang#161415 (Update expect messages in path docs to better follow guidelines) - rust-lang#161438 (Change triagebot backport to ping T-libs-fcp) - rust-lang#161442 (Add regression test for dead code on type alias used in impl self type) Failed merges: - rust-lang#160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`) implement [u8]::split_ascii_whitespace format fix
Rollup of 20 pull requests Successful merges: - rust-lang#161259 (move some attribute related structs out of rustc_attr_ir) - rust-lang#160853 (delegation: simplify matches on `FnKind`, minor refactorings) - rust-lang#161161 (proc_macro: add support for 16-bit targets) - rust-lang#159899 ( `GenericArgs::types` triage + possible fixes) - rust-lang#160459 (Use attribute parser for `deprecated` attribute checking) - rust-lang#160536 (Inline `String::into_raw_parts` and reuse `from_utf16` optimization) - rust-lang#160563 (Make `BorrowedCursor<'a, T>` covariant in `'a` and drop an indirection) - rust-lang#160595 (Clarify `str::split_at` docs) - rust-lang#160813 (Optimize linked list iterator performance) - rust-lang#161271 (doc: document safety requirements for core WTF-8) - rust-lang#161317 (LLVM 24: configure float-abi via module flag) - rust-lang#161320 (Only suggest `RUST_MIN_STACK` if maybe stack overflow) - rust-lang#161369 (Add regression test for confusing lifetime error message issue) - rust-lang#161393 (Configure LLM policy URL for triagebot) - rust-lang#161403 (splat-fn-ptr-ptr-tuple.rs: add `let` to avoid UB) - rust-lang#161409 (Add back `tests/rustdoc-gui/notable-trait.goml` test) - rust-lang#161410 (Fix rustdoc remapping `documentation` scope documentation) - rust-lang#161415 (Update expect messages in path docs to better follow guidelines) - rust-lang#161438 (Change triagebot backport to ping T-libs-fcp) - rust-lang#161442 (Add regression test for dead code on type alias used in impl self type) Failed merges: - rust-lang#160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`) implement [u8]::split_ascii_whitespace format fix
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (839342e): comparison URL. Overall result: no relevant changes - BENCHMARK(S) FAILED@rustbot label: -perf-regression ❗ ❗ ❗ ❗ ❗
❗ ❗ ❗ ❗ ❗ Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: missing data |
I noticed that comment
// This isn't done via collect::<Result<_, _>>() for performance reasons.explicitly states that this approach is wrong, butfrom_utf16leandfrom_utf16beare not using the same optimization.I believe
into_raw_partsis missing the#[inline]as any other similar functions in the standard library are marked either withinlineorinline(always).This is also related to #48994; whenever that fix lands, optimizing
from_utf16_unitswill results in these 3 functions getting optimized.