Skip to content
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

Updating sort algorithms #1233

Open
nazar-pc opened this issue Feb 16, 2025 · 2 comments
Open

Updating sort algorithms #1233

nazar-pc opened this issue Feb 16, 2025 · 2 comments

Comments

@nazar-pc
Copy link

Rust library today uses ipnsort and driftsort for unstable and stable sort respectively.

I'm wondering if it would make sense to switch to them in parallel implementations here too instead of pdqsort and timsort respectively.

@cuviper
Copy link
Member

cuviper commented Feb 17, 2025

Yes -- our current implementations were originally copied and adapted from the standard library, and we've synced some minor tweaks since then, but not that major rewrite yet. I'd be happy to see the new ones ported!

It might be even better if we can just do the parallel splits and merges on our own, and forward the rest to the standard library. I think that may be feasible for the unstable sort, but last time I looked, the buffer management of stable sorting is not amenable to that kind of arrangement.

@nazar-pc
Copy link
Author

I'd actually be interested in something like that being exposed in a public API. I already have a parallel operation that creates a bunch of vectors with intermediate results with the size roughly proportional to the performance of the corresponding CPU core.

What happens next is concatenating them into a new vector prior to running parallel sort. If there was only a way to efficiently sort intermediate results in their threads and them merge together into the final sorted output, that might potentially make the whole thing more efficient.

Sorting is a very non-negligible part of the performance-sensitive code in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants