Abstract
Set intersection is a fundamental operation in information retrieval and database systems. As data increasingly resides in main memory, traditional comparison-based algorithms become a bottleneck. This paper proposes a novel framework that leverages bit-level parallelism and the observation that real-world intersections are typically much smaller than the sets themselves. By partitioning sets into small groups and representing them as machine-word bit-vectors via hashing, the proposed approach achieves significant speedups—up to 50% over standard merge algorithms—while maintaining linear space complexity.
1. Introduction
Set intersection—identifying common elements across multiple lists—is a core operation for search engines and database management systems. For instance, a conjunctive query for "fast" AND "memory" requires intersecting the document lists for both terms. In modern low-latency applications, data is often stored in main memory. However, traditional algorithms like merging sorted lists or using skip lists often fail to exploit architectural features of modern CPUs, such as 64-bit word processing. Furthermore, these methods do not always capitalize on the fact that final intersections are typically orders of magnitude smaller than the input sets.
2. Methodology: Partitioning and Bit-Level Filtering
The proposed framework relies on a two-stage process: partitioning and bit-level filtering.
First, large sets are divided into small, manageable groups (approximately 8 elements each). Each group is then mapped into a small universe (e.g., 64 elements) using a hash function. This mapping is stored as a single machine word (a bit-vector), where the $i$-th bit is set if an element in the group hashes to $i$.
To intersect two groups, the algorithm performs a bitwise-AND on their respective machine words. If the result is zero, the intersection is guaranteed to be empty, allowing the algorithm to skip the actual elements entirely. If the result is non-zero, a refinement step recovers the actual intersection by checking only the elements that mapped to the overlapping bits. This approach effectively uses the bitwise-AND as a "cheap oracle," avoiding expensive memory accesses and comparisons for the vast majority of non-overlapping data.
The paper introduces two primary variants: IntGroup, which uses fixed-width partitions, and RanGroup, which utilizes randomized partitions based on hash prefixes. Additionally, a multi-resolution data structure is provided to handle cases where set sizes are highly skewed, allowing the algorithm to choose optimal partition sizes dynamically.
3. Experimental Evaluation
The algorithms were evaluated using three distinct datasets:
- Synthetic Data: Randomly generated sets with uniform distributions to test performance across various sizes and intersection ratios.
- Real-World Data: A corpus of 8 million Wikipedia documents.
- Real-World Workload: 10,000 frequent queries from the Bing Shopping portal, confirming that intersections are often at least 10x smaller than the smallest input set in 94% of cases.
4. Results and Analysis
Empirical results demonstrate that the proposed algorithms, particularly RanGroupScan, significantly outperform traditional methods.
On synthetic data, RanGroupScan was 40% to 50% faster than the standard Merge algorithm. In real-world workloads (Wikipedia/Bing), RanGroupScan was the fastest algorithm for over 61% of all queries. Unlike adaptive algorithms that struggle when set sizes are similar, these methods remain competitive with or superior to simple merges across almost all scenarios.
While the performance gain involves a space trade-off—requiring 37% to 87% more memory than standard uncompressed inverted indices—the authors demonstrate that these structures are amenable to effective compression.
5. Conclusion
By exploiting bit-level parallelism and the sparsity of intersections, the proposed partitioning and hashing framework offers a substantial performance boost for in-memory set intersection. While it introduces some memory overhead and requires preprocessing, its practical speed and robustness make it a compelling choice for modern high-performance search and database systems. Future work may explore leveraging wider SIMD instructions (e.g., AVX-512) to further enhance bit-parallelism.
Summary updated