rust/library/alloc/src
bors 684b3553f7 Auto merge of #124032 - Voultapher:a-new-sort, r=thomcc
Replace sort implementations

This PR replaces the sort implementations with tailor-made ones that strike a balance of run-time, compile-time and binary-size, yielding run-time and compile-time improvements. Regressing binary-size for `slice::sort` while improving it for `slice::sort_unstable`. All while upholding the existing soft and hard safety guarantees, and even extending the soft guarantees, detecting strict weak ordering violations with a high chance and reporting it to users via a panic.

* `slice::sort` -> driftsort [design document](https://github.com/Voultapher/sort-research-rs/blob/main/writeup/driftsort_introduction/text.md), includes detailed benchmarks and analysis.

* `slice::sort_unstable` -> ipnsort [design document](https://github.com/Voultapher/sort-research-rs/blob/main/writeup/ipnsort_introduction/text.md), includes detailed benchmarks and analysis.

#### Why should we change the sort implementations?

In the [2023 Rust survey](https://blog.rust-lang.org/2024/02/19/2023-Rust-Annual-Survey-2023-results.html#challenges), one of the questions was: "In your opinion, how should work on the following aspects of Rust be prioritized?". The second place was "Runtime performance" and the third one "Compile Times". This PR aims to improve both.

#### Why is this one big PR and not multiple?

* The current documentation gives performance recommendations for `slice::sort` and `slice::sort_unstable`. If for example only one of them were to be changed, this advice would be misleading for some Rust versions. By replacing them atomically, the advice remains largely unchanged, and users don't have to change their code.
* driftsort and ipnsort share a substantial part of their implementations.
* The implementation of `select_nth_unstable` uses internals of `slice::sort_unstable`, which makes it impractical to split changes.

---

This PR is a collaboration with `@orlp.`
2024-06-20 20:40:43 +00:00
..
alloc run alloc benchmarks in Miri and fix UB 2022-11-07 10:34:04 +01:00
boxed Convert some module-level // and /// comments to //!. 2024-06-20 09:23:18 +10:00
collections replace version placeholder 2024-06-11 16:52:02 +02:00
ffi replace version placeholder 2024-06-11 16:52:02 +02:00
raw_vec try_with_capacity for RawVec 2024-03-01 18:20:48 +00:00
rc UniqueRc: support allocators and T: ?Sized. 2024-06-11 15:16:47 -07:00
slice Revert panic_safe test changes 2024-06-17 22:05:35 +02:00
sync Fix some Arc allocator leaks 2024-01-28 18:33:34 +01:00
testing Share testing utilities with non-btree test cases 2022-05-02 10:07:50 +02:00
vec Add blank lines after module-level //! comments. 2024-06-20 09:23:20 +10:00
alloc.rs step cfgs 2024-03-20 08:49:13 -04:00
borrow.rs Impl DerefPure for more std types 2024-04-05 00:02:42 +02:00
boxed.rs remove cfg(bootstrap) 2024-06-11 16:52:04 +02:00
fmt.rs Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubilee 2024-05-12 08:34:32 +00:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Stabilise c_unwind 2024-06-19 13:54:51 +01:00
macros.rs Update doc for alloc::format! and core::concat! 2023-09-06 15:11:21 +02:00
raw_vec.rs Avoid more NonNull-raw-NonNull roundtrips in Vec 2024-04-12 18:14:29 -04:00
rc.rs Rollup merge of #126285 - kpreid:unique-rc, r=dtolnay 2024-06-14 12:23:37 +02:00
slice.rs Fix wrong big O star bracing in the doc comments 2024-06-20 18:07:04 +02:00
str.rs fix #124714 str.to_lowercase sigma handling 2024-05-08 17:05:10 +02:00
string.rs Auto merge of #99969 - calebsander:feature/collect-box-str, r=dtolnay 2024-05-19 02:13:06 +00:00
sync.rs Update Arc::try_unwrap() docs 2024-06-16 09:07:08 +02:00
task.rs lib: fix some unnecessary_cast clippy lint 2024-03-25 23:19:40 +03:00
tests.rs remove redundant imports 2023-12-10 10:56:22 +08:00