LeCo: Lightweight Compression via Learning Serial Correlations

Yihao Liu, Xinyu Zeng, Huanchen Zhang

TL;DR

LeCo is a novel framework that treats lossless data compression as a machine learning regression task. By automatically learning serial correlations in columnar data and storing only the "model + deltas," it achieves a Pareto improvement—simultaneously outperforming state-of-the-art methods in both compression ratio and random access speed.

What Problem Does This Paper Address?

Modern analytical databases (column stores) rely on lightweight compression algorithms like Frame-of-Reference (FOR), Delta Encoding, and Run-Length Encoding (RLE) to minimize storage and maximize disk/network bandwidth. However, these traditional methods are "ad-hoc" solutions designed for very simple patterns: RLE handles repetitions, and Delta handles basic step functions.

The authors identify a major gap: real-world data often contains more sophisticated serial correlations (e.g., piecewise linearity or complex curves) that these simple algorithms miss. Furthermore, while "heavyweight" block compression (like zstd) offers high ratios, it often becomes a CPU bottleneck and lacks fast random access—a critical requirement for modern hybrid transactional/analytical processing (HTAP) workloads. LeCo aims to bridge this gap by using machine learning to extract complex patterns while remaining "lightweight" enough for high-performance query execution.

Methods

LeCo introduces a "Model + Delta" framework. Instead of storing raw values, it fits a lightweight regression model to a sequence of values and stores the model parameters plus the prediction errors (deltas).

Key components include:

  • The Regressor: Unlike standard ML that minimizes Mean Squared Error ($L_2$ norm), LeCo minimizes the maximum error ($L_\infty$ norm). This is crucial because deltas are stored in a fixed-length bit-packed array; the bit-width of the entire array is dictated by the single largest error.
  • The Partitioner: Since real-world data distributions change, LeCo partitions sequences into segments. It offers Fixed-Length Partitioning (for fastest random access) and a greedy Variable-Length "Split and Merge" algorithm (for maximum compression).
  • Hyperparameter-Advisor: An offline-trained classifier that analyzes data features (like log-scale range and subrange trends) to automatically select the best model type (e.g., linear, polynomial, or even trigonometric) for a given dataset.
  • String Extension: LeCo extends to strings by mapping them to large integers using order-preserving techniques and adaptive padding to minimize deltas.

Datasets

The authors evaluated LeCo against a massive suite of benchmarks:

  • Synthetic: Linear, normal, Poisson, and non-linear distributions (e.g., cosmos, polylog).
  • Real-World (SOSD Benchmark): booksale, facebook, wiki, and osm.
  • Tabular/Analytical: Data from TPC-H, TPC-DS, MovieLens (movieid), and US House Prices.
  • Strings: Email addresses, hexadecimal strings, and English words.
  • System Integration: Evaluated within Apache Arrow, Parquet, and RocksDB.

Key Insights and Ideas

  • Compression as Regression: The core "aha moment" is that extracting serial correlation is fundamentally a regression task. If a model captures the "common pattern," the remaining "noise" (deltas) requires significantly fewer bits to represent.
  • Generalization of Classics: The authors show that traditional methods are just special cases of LeCo: FOR is a horizontal line model, and Delta encoding is a basic step function.
  • Computation Pruning: Because the models are often monotonic, the decoder can use the model's prediction plus the known maximum error to "prune" entire blocks during range queries without decompressing them, similar to how zone maps work but at a much finer grain.
  • The Precision Trade-off: In variable-length partitioning, the authors found that "over-splitting" data into too many small partitions can actually hurt compression because the overhead of storing many model parameters outweighs the savings in delta bit-widths. Their "merge" phase specifically addresses this.

Key Results

  • Pareto Improvement: LeCo-fix (fixed-length) achieves better compression than FOR and Elias-Fano while maintaining comparable random access speeds.
  • Compression Ratios: On "locally easy" datasets, LeCo improved compression ratios by 40.9% on average over FOR. On specific real-world datasets like house_price, the variable-length variant achieved nearly 90% better compression than fixed-length baselines.
  • Query Speedup: When integrated into the Apache Arrow execution engine, LeCo provided up to a 5.2x speedup for analytical queries due to reduced I/O and efficient SIMD-friendly decoding.
  • System Throughput: In RocksDB, using LeCo for index block compression resulted in a 16% increase in total system throughput by fitting more index data into the block cache.

Limitations and Future Work

  • Training Overhead: While decompression is lightning-fast, the "learning" phase (compression) is an order of magnitude slower than simple methods like FOR because it requires multiple passes and optimization solvers. This makes it best suited for "write-once, read-many" scenarios.
  • Immutable Data: The current prototype targets immutable columnar formats. Handling frequent updates would require efficient model retraining or "gapped" arrays, which the authors suggest as a direction for future work.
  • Model Complexity: While higher-order models (like sine waves) help in niche cases, the authors note that for most integer benchmarks, linear models provide the best balance of complexity and performance.

Summary updated

BibTeX
@article{liu2024leco,
  author = {Yihao Liu and Xinyu Zeng and Huanchen Zhang},
  title = {{LeCo: Lightweight Compression via Learning Serial Correlations}},
  journal = {Proc. ACM Manag. Data},
  year = {2024},
  doi = {10.1145/3639320},
}
Figure