Introduction
Log analysis is a critical component of modern system diagnostics, security auditing, and business intelligence. However, as data volumes scale into the terabyte and petabyte range, traditional "brute-force" regular expression (regex) searching becomes a significant performance bottleneck. Log data presents unique challenges: high granularity (billions of small lines), strict storage overhead requirements (traditional indexes often exceed 50% of data size), and high query selectivity, where most processing time is spent confirming non-matches.
The REI Framework
To address these challenges, we propose REI (Regular Expression Indexing), a lightweight framework designed to accelerate regex queries by filtering out non-matching log lines before they reach the regex engine. The system relies on three primary pillars:
- Bigram Selection: REI identifies a set of "important" bigrams (two-character sequences) based on query workloads. Bigrams strike an optimal balance between filtering power and index size compared to longer n-grams.
- Bit-Vector Filtering: For each log line or group of lines, REI maintains a compact bit-vector. Each bit indicates the presence or absence of a specific bigram from the selected set.
- The Negative Index Property: When a regex query is executed, REI extracts required bigrams from the pattern. If the index indicates a log line lacks any of these bigrams, the line is skipped entirely, avoiding expensive evaluation by the regex engine (e.g., Google's RE2).
Experimental Evaluation
We evaluated REI against state-of-the-art non-indexed engines like BLARE using real-world production workloads, including a 13.5 GB database log (DB-X) with 9,000 queries and a 100 GB system exploration dataset (Sys-Y).
Performance and Efficiency
REI demonstrates substantial performance gains, achieving a 14× speedup in matching time compared to BLARE. This performance is achieved with minimal storage overhead; for the DB-X dataset, the index requires only 2.1% extra space, increasing total storage from 13.50 GB to 13.78 GB.
Key Insights
- Query-Driven Indexing: Selecting bigrams based on query frequency, rather than data frequency, provides near-optimal filtering with significantly lower computational overhead during index construction.
- Generalization: In scenarios where future queries are unknown, an "EnglishIndex" strategy—using common English bigrams—still yields significant speedups due to the natural language characteristics of most logs.
Conclusion
REI provides a highly efficient solution for large-scale log search. By leveraging a compact bit-vector index of bigrams, it enables massive skipping of non-matching data with negligible storage costs. Future work includes integrating REI into columnar storage formats like Apache Parquet and exploring bitmap compression techniques to further optimize space efficiency.
Summary updated