HackerPapers

arXiv:1706.00990cs.DS

A Fast x86 Implementation of Select

Prashant Pandey, Michael A. Bender, Rob Johnson

Abstract

Rank and select are fundamental operations in succinct data structures, that is, data structures whose space consumption approaches the information-theoretic optimal. The performance of these primitives is central to the overall performance of succinct data structures. Traditionally, the select operation is the harder to implement efficiently, and most prior implementations of select on machine words use 50--80 machine instructions. (In contrast, rank on machine words can be implemented in only a handful of instructions on machines that support POPCOUNT.) However, recently Pandey et al. gave a new implementation of machine-word select that uses only four x86 machine instructions; two of which were introduced in Intel's Haswell CPUs. In this paper, we investigate the impact of this new implementation of machine-word select on the performance of general bit-vector-select. We first compare Pandey et al.'s machine-word select to the state-of-the-art implementations of Zhou et al. (which is not specific to Haswell) and Gog et al. (which uses some Haswell-specific instructions). We exhibit a speedup of 2X to 4X. We then study the impact of plugging Pandey et al.'s machine-word select into two state-of-the-art bit-vector-select implementations. Both Zhou et al.'s and Gog et al.'s select implementations perform a single machine-word select operation for each bit-vector select. We replaced the machine-word select with the new implementation and compared performance. Even though there is only a single machine- word select operation, we still obtained speedups of 20% to 68%. We found that the new select not only reduced the number of instructions required for each bit-vector select, but also improved CPU instruction cache performance and memory-access parallelism.

arXiv comments
Keywords and phrases Succinct data structures, Rank and Select operation
Journal reference
DOI
Subjects
cs.DSData Structures and Algorithms

On Hacker News

Linked by 3 identifiable commenters in 3 comments across 3 threads, from May 2020 to Mar 2025. Found in 2 HN submissions from Jun 2017 to Oct 2018. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments3 threads

  1. Succinct Data Structures 1 comment
    • I can speak a bit about one of the approaches: "Practical Entropy-Compressed Rank/Select Dictionary" by Daisuke Okanohara and Kunihiko Sadakane. This presents two different variants: One for dense (i.e. more than 50% of the bits are set) and one for sparse. The dense…

      judofyrView on HNParent context

  2. The NSA Instruction (2019) 1 comment
    • This paper was first published in 2008 (and has since been beaten several times over by more modern techniques). a quick glance doesn't suggest that there's anything obviously new in this version, is there a reason it has a new date? Original…

      dgacmuView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.