Skip to content

Add StableRadixSort improvements and hybrid_vector container#2662

Open
LinnJz wants to merge 1 commit into
facebook:mainfrom
LinnJz:add-stable-radix-sort-hybrid-vector
Open

Add StableRadixSort improvements and hybrid_vector container#2662
LinnJz wants to merge 1 commit into
facebook:mainfrom
LinnJz:add-stable-radix-sort-hybrid-vector

Conversation

@LinnJz

@LinnJz LinnJz commented Jun 24, 2026

Copy link
Copy Markdown

This PR optimizes StableRadixSort and introduces hybrid_vector (with
HybridAlloc) to support its runtime-sized bucket allocations.

StableRadixSort

  • Rewrite with LSD/MSD traversal + sequential/parallel execution (via OpenMP),
    offering four combined modes
  • Add compile-time configuration options (RadixSortOptions, BitsPerPass, sign
    handling, NaN positioning)
  • Unified interface via radixSort()
  • Enhanced benchmarks and test coverage

hybrid_vector & HybridAlloc

  • hybrid_vector: a fixed-capacity vector with stack-first, heap-fallback
    storage (threshold configurable, default 1024 bytes)
  • HybridAlloc: RAII-free stack-or-heap allocation macros
  • Motivation: StableRadixSort's OpenMP parallel path needs per-thread bucket
    storage. The number of threads is runtime-known, so stack-only allocation
    (alloca) isn't viable directly. BitsPerPass::Bits8 (256 entries) fits stack;
    Bits16 (65536 entries) requires heap. hybrid_vector provides a unified
    abstraction that auto-selects the backing storage.

Additional

  • Extend CPortability.h with platform detection macros
  • Extend Iterator.h with new iterator utilities
  • Add folly/docs/hybrid_vector.md documentation
  • Update CMakeLists.txt and BUCK files for all new targets

@meta-cla meta-cla Bot added the CLA Signed label Jun 24, 2026
@LinnJz LinnJz closed this Jun 24, 2026
@LinnJz LinnJz reopened this Jun 24, 2026
@LinnJz LinnJz force-pushed the add-stable-radix-sort-hybrid-vector branch from bd1547c to 1cea4d7 Compare June 24, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant