[Paper Review] A Fast x86 Implementation of Select
This paper presents PTSelect, a highly optimized x86 implementation of the select operation on 64-bit words using only four instructions—two of which are Intel Haswell-specific (pdep and tzcnt). It achieves 2× to 4× speedup over prior state-of-the-art machine-word select implementations and delivers 20% to 68% performance gains in full bit-vector select operations by improving instruction-level parallelism and memory access efficiency, even though only one machine-word select is invoked per bit-vector select.
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.
Motivation & Objective
- To improve the performance of the select operation in succinct data structures, which is critical for their practical efficiency.
- To address the performance bottleneck caused by slow machine-word select implementations, which traditionally require 50–80 instructions.
- To evaluate the impact of a new, highly optimized machine-word select implementation (PTSelect) on end-to-end bit-vector select performance.
- To investigate how instruction count and memory-level parallelism affect performance in large-scale bit-vector operations.
Proposed method
- Implementing machine-word select using only four x86 instructions: pdep (parallel bit deposit) and tzcnt (trailing zero count), both introduced in Intel Haswell.
- Replacing traditional broadword or SSE-based select implementations with PTSelect in two state-of-the-art bit-vector select libraries: CS-Poppy and SDSL.
- Measuring performance across varying bit-vector sizes to isolate the effects of instruction count, cache misses, and memory-level parallelism.
- Analyzing CPU instruction window utilization and concurrent memory access patterns to explain performance differences.
- Using a custom benchmark suite based on Zhou et al.’s CS-Poppy to compare execution time and memory parallelism across implementations.
- Evaluating both machine-word select and full bit-vector select performance to isolate the contribution of the optimized primitive.
Experimental results
Research questions
- RQ1How does PTSelect compare to existing machine-word select implementations in terms of raw performance and instruction count?
- RQ2Why does PTSelect outperform other implementations even when memory latency dominates for large bit vectors?
- RQ3To what extent does reducing instruction count in machine-word select improve overall bit-vector select performance?
- RQ4How does instruction-level parallelism and memory-level parallelism influence the performance of select operations in large data structures?
- RQ5Can a minimal instruction count in a low-level primitive like machine-word select lead to significant performance gains in higher-level succinct data structures?
Key findings
- PTSelect achieves 2× to 4× speedup over CS-Poppy and SDSL on machine-word select benchmarks, despite using only 12 instructions compared to 80 and 49.
- The performance gain in full bit-vector select is 20% to 68% when replacing the default machine-word select in CS-Poppy with PTSelect.
- Even though only one machine-word select is invoked per bit-vector select, performance improves significantly with larger bit vectors due to increased memory-level parallelism.
- PTSelect enables 8 concurrent memory accesses on average, compared to 3 for CS-Poppy and 4 for SDSL, due to its shorter instruction sequence fitting more operations in the CPU’s instruction window.
- The performance advantage of PTSelect is attributed not only to fewer instructions but also to higher memory-level parallelism, which increases throughput on modern CPUs.
- The results suggest that instruction count and parallelism are critical factors in low-level primitives, even when memory latency is the dominant cost.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.