Benchmarking Learned Indexes

Ryan Marcus, Andreas Kipf, Alexander van Renen, Mihail Stoian, Sanchit Misra, Alfons Kemper, Thomas Neumann, Tim Kraska · DOI

Introduction

Learned index structures have emerged as a promising alternative to traditional indexing methods like B-Trees and Tries. By leveraging machine learning models to approximate the underlying data distribution, these structures aim to provide faster lookups with a significantly smaller memory footprint. This paper presents a comprehensive, open-source benchmark evaluating highly tuned learned indexes against state-of-the-art traditional baselines on real-world datasets. The results demonstrate that learned indexes offer superior size-to-performance tradeoffs for read-only, in-memory workloads, primarily due to a substantial reduction in CPU cache misses.

Background and Motivation

Since their inception, learned indexes have been a subject of debate. Critics often argued that early evaluations relied on synthetic datasets that were either too easy for models to memorize or unrepresentative of real-world complexity. Furthermore, the lack of standardized, open-source implementations made it difficult to conduct fair comparisons. For instance, previous studies claimed certain new models outperformed the original Recursive Model Index (RMI), but these comparisons often used unoptimized baselines. To address these issues, the authors developed a standardized benchmarking suite featuring highly tuned versions of both learned and traditional indexes.

Learned Index Architectures

The core idea behind a learned index is to treat the index as a model that predicts the position of a key within a sorted array. This is achieved by approximating the Cumulative Distribution Function (CDF) of the dataset.

Learned indexes approximate the Cumulative Distribution Function (CDF) of the dataset to predict key positions.

The benchmark evaluates three primary learned structures:

  • Recursive Model Indexes (RMI): A multi-stage, top-down architecture where models at one level select a sub-model at the next level to refine the position estimate.
  • Radix Spline (RS): A bottom-up approach that uses a linear spline to approximate the CDF, indexed by a radix table for fast initial lookups.
  • Piecewise Geometric Model (PGM): A multi-level structure based on piecewise linear regression that provides provable error bounds on position estimates.

These are compared against traditional structures such as the STX B-Tree, the Adaptive Radix Tree (ART), and various high-performance hash tables (e.g., Cuckoo, Robinhood).

Experimental Setup: Datasets

The evaluation uses four large-scale, real-world datasets, each containing 200 million 64-bit integers. These datasets represent different distribution characteristics:

  • amzn: Popularity data for books on Amazon.
  • face: Randomly sampled user IDs from Facebook.
  • osm: Cell IDs representing geographic locations from OpenStreetMap.
  • wiki: Timestamps of edits made to Wikipedia.
CDF plots for the four real-world datasets: amzn, face, osm, and wiki.

The osm dataset is particularly challenging because it represents 2D map data flattened into a 1D Hilbert curve, resulting in a highly erratic CDF that is difficult for simple linear models to approximate accurately.

Analysis of Performance

The study reveals several key insights into why learned indexes perform well:

  1. Pareto Dominance: For most datasets, learned indexes occupy the Pareto frontier of the lookup time vs. index size tradeoff. Computing a location mathematically is often faster than traversing multiple levels of a pointer-heavy tree structure.
  2. Cache Efficiency: The primary performance driver is the reduction in CPU cache misses. Learned indexes typically require fewer memory fetches per lookup than traditional trees, keeping the CPU pipeline busy.
  3. Branching Paradox: Interestingly, indexes with higher branch misprediction rates sometimes performed better. This suggests that learned models benefit from modern CPU speculative execution, whereas traditional structures may be over-optimized to avoid branches at the expense of increased instruction counts.
  4. Tuning Matters: Proper auto-tuning is essential. When RMI was correctly tuned, it significantly outperformed other models, reversing previous claims in the literature.

Experimental Results

  • Efficiency: On the amzn dataset, an RMI index achieved a 220ns lookup time with only a 1MB footprint. In contrast, a B-Tree of the same size required 650ns.
  • Throughput: Learned indexes scale well with multithreading. Structures like PGM and FAST achieved nearly 30x throughput on 40 threads, as their low cache-miss rates prevent memory bandwidth from becoming a bottleneck.
  • Hashing vs. Modeling: While hash tables like CuckooMap remain faster for raw lookups (e.g., 114ns), they require orders of magnitude more memory (1.5GB vs. 48MB for an RMI) and do not support range queries.
  • Build Overhead: Traditional trees are faster to construct. Building an RMI on the largest dataset took approximately 80 seconds, compared to just a few seconds for a B-Tree.

Conclusion and Future Directions

The benchmark confirms that learned indexes are a viable and often superior choice for read-only, in-memory workloads. However, the authors note that testing in isolation (tight loops) can exaggerate performance due to caching effects, although they employed cold caches and memory fences to mitigate this. Additionally, learned models struggle with data lacking local structure, such as the osm dataset. Future research should focus on extending these models to handle dynamic read/write workloads, developing multi-dimensional learned indexes for complex spatial data, and further investigating the interaction between model architecture and hardware-level speculative execution.

Summary updated

BibTeX
@article{marcus2020benchmarking,
  author = {Ryan Marcus and Andreas Kipf and Alexander van Renen and Mihail Stoian and Sanchit Misra and Alfons Kemper and Thomas Neumann and Tim Kraska},
  title = {{Benchmarking Learned Indexes}},
  journal = {Proc. VLDB Endow.},
  year = {2020},
  doi = {10.14778/3421424.3421425},
}
Figure