drain3
Fast log template extraction via fixed-depth prefix trees.
Rust port of logpai/Drain3. Splits log lines into tokens, clusters them by a prefix tree keyed on token count, and replaces variable tokens with a param placeholder (<*> by default).
Usage
use Config;
let samples: = vec!;
let matcher = train.unwrap;
let = matcher.match_line;
assert!;
assert_eq!;
Performance
Key optimizations ported from the Go implementation:
- First/last token prefilter — bypasses tree descent for matching via binary-search lookups (3–5× speedup on typical workloads)
- Frozen dictionary — read-only sorted-array token→ID map replaces HashMap on the match path
- hasParamFirst quick rejection — instantly rejects lines with unknown first tokens without tokenization
- Anchor checks — rejects non-matching candidates in 2 comparisons
- Scratch buffer reuse — tokenization buffer reused across calls
License
Apache-2.0