Skip to content

use sort_unstable to sort primitive types #76541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2020

Conversation

matthiaskrgr
Copy link
Member

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive
@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 9, 2020
@leonardo-m
Copy link

Can't sort perform by itself this optimization inside?

@matthiaskrgr
Copy link
Member Author

Hmm, it may be possible to have a custom sort() impl for slices of primitives and use sort::quicksort() (unstable sort) instead of merge_sort() under the hood, but I don't know what kind of dangers this implies. I'm wondering what the libs team thinks.

sort
sort_unstable

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can make an issue if you want to look into performing this optimisation within sort.

@davidtwco
Copy link
Member

@bors r+ rollup=never (might have a perf impact)

@bors
Copy link
Collaborator

bors commented Sep 10, 2020

📌 Commit b4935e0 has been approved by davidtwco

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2020
@matthiaskrgr
Copy link
Member Author

Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/default.20to.20unstable.20sort.20when.20sorting.20primitive.20type.20slices

May make an issue if this remains unanswered so the idea does not get lost :)

@bors
Copy link
Collaborator

bors commented Sep 10, 2020

⌛ Testing commit b4935e0 with merge 49888362e2fbf2738f473ef73621c78475d32d34...

@bors
Copy link
Collaborator

bors commented Sep 10, 2020

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 10, 2020
@lqd
Copy link
Member

lqd commented Sep 10, 2020

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2020
@bors
Copy link
Collaborator

bors commented Sep 11, 2020

⌛ Testing commit b4935e0 with merge f8b002441bba6130859a9fe7a8b86c2d39196ca2...

@bors
Copy link
Collaborator

bors commented Sep 11, 2020

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 11, 2020
@matthiaskrgr
Copy link
Member Author


failures:

---- [run-make] run-make-fulldeps/long-linker-command-lines stdout ----

error: make failed
status: exit code: 2
command: "make"
stdout:
------------------------------------------
DYLD_LIBRARY_PATH="/Users/runner/work/1/s/build/x86_64-apple-darwin/test/run-make-fulldeps/long-linker-command-lines/long-linker-command-lines:/Users/runner/work/1/s/build/x86_64-apple-darwin/stage2/lib:" '/Users/runner/work/1/s/build/x86_64-apple-darwin/stage2/bin/rustc' --out-dir /Users/runner/work/1/s/build/x86_64-apple-darwin/test/run-make-fulldeps/long-linker-command-lines/long-linker-command-lines -L /Users/runner/work/1/s/build/x86_64-apple-darwin/test/run-make-fulldeps/long-linker-command-lines/long-linker-command-lines  foo.rs -g -O
RUSTC="/Users/runner/work/1/s/build/x86_64-apple-darwin/stage2/bin/rustc" DYLD_LIBRARY_PATH="/Users/runner/work/1/s/build/x86_64-apple-darwin/test/run-make-fulldeps/long-linker-command-lines/long-linker-command-lines:/Users/runner/work/1/s/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib:" /Users/runner/work/1/s/build/x86_64-apple-darwin/test/run-make-fulldeps/long-linker-command-lines/long-linker-command-lines/foo
attempt: 100
attempt: 200
attempt: 300

------------------------------------------
stderr:
------------------------------------------
thread 'main' panicked at 'status: exit code: 1
stdout:

stderr:
error: couldn't read /Users/runner/work/1/s/build/x86_64-apple-darwin/test/run-make-fulldeps/long-linker-command-lines/long-linker-command-lines/bar.rs: stream did not contain valid UTF-8

error: aborting due to previous error

', foo.rs:76:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
make: *** [all] Error 101

Hm, since this test did not fail previously (when the build timed out) I assume this is spurious?

@Mark-Simulacrum
Copy link
Member

Seems quite likely, though I am a bit surprised by spurious failures in that test.

@bors retry run-make-fulldeps/long-linker-command-lines

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 11, 2020
@bors
Copy link
Collaborator

bors commented Sep 11, 2020

⌛ Testing commit b4935e0 with merge 285c7137e0fdfdd91de86ed9d178e295fe2b8569...

@bors
Copy link
Collaborator

bors commented Sep 11, 2020

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 11, 2020
@davidtwco
Copy link
Member

This is one unlucky PR..
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2020
@bors
Copy link
Collaborator

bors commented Sep 14, 2020

⌛ Testing commit b4935e0 with merge 8d505c0c5330ef924a4583158ab3a50d432c13d1...

@bors
Copy link
Collaborator

bors commented Sep 14, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 14, 2020
@davidtwco
Copy link
Member

davidtwco commented Sep 14, 2020

---- workspaces::relative_rustc stdout ----
running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/cargo build`
running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/cargo build`
thread 'workspaces::relative_rustc' panicked at '
Expected: execs
    but: exited with exit code: 101
--- stdout

--- stderr
error: could not execute process `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/cit/t1927/lib/./foo -vV` (never executed)

Caused by:
  Text file busy (os error 26)
', src/tools/cargo/crates/cargo-test-support/src/lib.rs:832:13

Another spurious failure?

@matthiaskrgr
Copy link
Member Author

Hmm, I rebased and retried again locally and didn't see any of the these test failures.

@Mark-Simulacrum
Copy link
Member

Okay, let's try again. @bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2020
@bors
Copy link
Collaborator

bors commented Sep 14, 2020

⌛ Testing commit b4935e0 with merge 9b41541...

@bors
Copy link
Collaborator

bors commented Sep 14, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: davidtwco
Pushing 9b41541 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 14, 2020
@bors bors merged commit 9b41541 into rust-lang:master Sep 14, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 14, 2020
@matthiaskrgr matthiaskrgr deleted the unstable_sort branch January 25, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants