pdqsort
fluxsort
Our great sponsors
pdqsort | fluxsort | |
---|---|---|
9 | 12 | |
2,283 | 661 | |
- | - | |
0.0 | 6.4 | |
5 months ago | 3 months ago | |
C++ | C | |
zlib License | The Unlicense |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
pdqsort
- Pattern-Defeating Quicksort (Pdqsort)
-
Faster sorting algorithm
I found that this exists: https://github.com/orlp/pdqsort
-
How sorting algorithms work
Their sort_unstable algorithm is based on this pattern-defeating quicksort.
-
Timsort – the fastest sorting algorithm you’ve never heard of
Closely related is pattern defeating quicksort ( https://github.com/orlp/pdqsort ), which adapts quicksort to take advantage of sorted runs. I've adapted a few quicksorts to pdqsort and seen good speedups (as people were often sorting partially sorted data)
Basically: Timsort is to mergesort as pdqsort is to quicksort
- I tried creating a sorting algorithm in C language.
- Do Low-Level Optimizations Matter?
-
Discussion Thread
I was thinking of optimal C++ over native types. I just spoke up because if your intuition of quicksort is that 50k elements should take 20ms you’re drastically underestimating computer performance. They’re crazy fast and optimized sorting algorithms are downright scary.
-
Beating Up on Qsort (2019)
Just for fun, I added pdqsort to the benchmark:
https://github.com/orlp/pdqsort
Here are some of the results on an Ivy Bridge hackintosh:
size, qsort, inline, sort, stable_sort, pdqsort, radix7
-
Which sorting algorithm did you implement in your programming language?
sort_unstable is a pattern-defeating quicksort (https://github.com/orlp/pdqsort) added with RFC#1884 (https://github.com/rust-lang/rfcs/pull/1884).
fluxsort
- Fluxsort: A stable quicksort, now faster than Timsort for both random and ordered data
-
10~17x faster than what? A performance analysis of Intel x86-SIMD-sort (AVX-512)
Steps to build a fast, highly adaptive AVX-512 sorting algorithm:
- Clone fluxsort (https://github.com/scandum/fluxsort)
- Replace the partitioning code in flux_default_partition and flux_reverse_partition with the obvious AVX-512 version using a compare and two compress instructions
- If you're feeling ambitious, swap out the small array sorting, or incorporate crumsort's fulcrum partition for larger arrays.
I know why I haven't done this: my computer doesn't have AVX-512, and hardly anyone else's seems to. Maybe a couple Zen 4 owners. I'm less clear on why the tech giants are reinventing the wheel to make these sorting alrogithms that don't even handle pre-sorted data rather than working with some of the very high-quality open source stuff out there. Is adaptivity really considered that worthless?
Fluxsort makes this particularly simple because it gets great performance out of a stable out-of-place partition. It's a bit newer; maybe the authors weren't aware of this work. But these algorithms both use (fairly difficult) in-place partitioning code; why not slot that into the well-known pdqsort?
- A Rust port of crumsort, up to 75% faster than pdqsort
- GitHub - scandum/fluxsort: A branchless stable quicksort / mergesort hybrid.
-
Reinforcement learned branchless sorting functions for sort3, sort4 and sort5 were landed in LLVM
With the right code and code-gen https://github.com/scandum/fluxsort/issues/5 these can be excellent at exploiting wide super-scalar architectures. I use them in both ipn_stable and to a larger extent in ipn_unstable which even uses the lesser known median networks for pivot selection. That said, I've done a lot of experiments with smaller sorting networks, sort3/4/5 as used in libcxx. And I found that they only look good in synthetic micro-benchmarks. If all your program does, is sort inputs of one specific size 3/4/5 in a hot loop and does nothing else, yes they are faster than insertion sort. But as soon as your application does some non-trivial amount of other work before calling sort again, the code complexity and additional branching required to get to that sort network is not worth it anymore. Depending on your architecture, my findings suggest they only start pulling ahead beginning at sizes 8-12.
-
Changing std:sort at Google’s Scale and Beyond
Any chance you could comment on fluxsort[0], another fast quicksort? It's stable and uses a buffer about the size of the original array, which sounds like it puts it in a similar category as glidesort. Benchmarks against pdqsort at the end of that README; I can verify that it's faster on random data by 30% or so, and the stable partitioning should mean it's at least as adaptive (but the current implementation uses an initial analysis pass followed by adaptive mergesort rather than optimistic insertion sort to deal with nearly-sorted data, which IMO is fragile). There's an in-place effort called crumsort along similar lines, but it's not stable.
I've been doing a lot of work on sorting[2], in particular working to hybridize various approaches better. Very much looking forward to seeing how glidesort works.
[0] https://github.com/scandum/fluxsort
[1] https://github.com/scandum/crumsort
[2] https://mlochbaum.github.io/BQN/implementation/primitive/sor...
- I tried creating a sorting algorithm in C language.
- Fluxsort: A stable adaptive partitioning comparison sort
-
Hacker News top posts: Jul 25, 2021
Fluxsort: A stable adaptive partitioning comparison sort\ (0 comments)
What are some alternatives?
American Fuzzy Lop - american fuzzy lop - a security-oriented fuzzer
crumsort - A branchless unstable quicksort / mergesort that is highly adaptive.
quadsort - Quadsort is a branchless stable adaptive mergesort faster than quicksort.
ZBar - Clone of the mercurial repository http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar
awesome-algorithms - A curated list of awesome places to learn and/or practice algorithms.
ZXing - ZXing ("Zebra Crossing") barcode scanning library for Java, Android
awesome-theoretical-computer-science - The interdicplinary of Mathematics and Computer Science, Distinguisehed by its emphasis on mathemtical technique and rigour.
C++ Format - A modern formatting library
xeus-cling - Jupyter kernel for the C++ programming language
ZPM - The C++ package manager based on premake5
SHOGUN - Shōgun