Skip to content

fix: LogParser 7x ARM64 regression — restore DFA for (?m)^#149

Merged
kolkov merged 4 commits intomainfrom
hotfix/remove-dfa-multiline-downgrade
Mar 23, 2026
Merged

fix: LogParser 7x ARM64 regression — restore DFA for (?m)^#149
kolkov merged 4 commits intomainfrom
hotfix/remove-dfa-multiline-downgrade

Conversation

@kolkov
Copy link
Contributor

@kolkov kolkov commented Mar 23, 2026

Summary

Fix LogParser 7x regression on ARM64 reported by @kostya (#124).

  • Remove false DFA downgrade for (?m)^ — lazy DFA already handles multiline line anchors correctly via StartByteMap/StartLineLF (identical to Rust). The downgrade forced 4 LangArena patterns to byte-by-byte NFA scan.
  • Restore partial prefilter for (?i) alternation overflow — literal extractor returned empty Seq on overflow, killing all prefilter for suspicious pattern (549 NFA states). Now trims to 3-byte prefixes (Rust approach), marks inexact.
  • Guard NFA candidate loop with IsComplete() — incomplete prefilters cannot be used as correctness gates (would miss truncated branches). NFA falls through to full scan.

Results (LangArena simulation, 13 patterns)

Version Total
v0.12.14 (baseline) 221ms
v0.12.16 (regressed) 2335ms
v0.12.17 185ms

Root cause analysis: docs/dev/research/v01216-arm64-regression.md

Test plan

  • go test ./... — all pass
  • TestStdlibCompatibility — 38/38 PASS, 0 SKIP
  • golangci-lint run — 0 issues
  • CI: 3 platforms + lint + 386
  • regex-bench: Benchmark + LangArena + macOS ARM64

kolkov added 2 commits March 23, 2026 11:32
adjustForAnchors() incorrectly routed (?m)^ patterns from UseDFA to
UseNFA, claiming DFA can't verify multiline line anchors. The lazy DFA
already handles (?m)^ correctly via StartByteMap/StartLineLF — identical
to Rust regex approach. Verified with direct DFA tests.

The downgrade caused 4 LangArena patterns (api_calls, post_requests,
passwords, sessions) to use byte-by-byte NFA scan instead of DFA —
catastrophic on ARM64 without SIMD (LogParser 2s -> 14s on M1).

LangArena total: 2335ms -> 185ms (12.6x faster).
Root cause: docs/dev/research/v01216-arm64-regression.md
…NFA candidate loop

Literal extractor returned empty Seq on cross-product overflow (>250),
killing all prefilter literals for patterns like (?i)(eval|system|exec|...).
Now trims to 3-byte prefixes + dedup (Rust approach), marks inexact.

Also guards NFA candidate loop with IsComplete() — incomplete prefilters
cannot be used as correctness gates (would miss branches whose literals
were truncated). NFA falls through to full scan instead.

suspicious: UseNFA without prefilter (113ms) -> with FatTeddy (1ms).
Stdlib compat: 38/38 PASS.
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link

github-actions bot commented Mar 23, 2026

Benchmark Comparison

Comparing main → PR #149

Summary: geomean 120.2n 120.0n -0.24%

⚠️ Potential regressions detected:

geomean                               ³                +0.00%               ³
geomean                               ³                +0.00%               ³
geomean                         ³                +0.00%               ³
geomean                         ³                +0.00%               ³
AhoCorasickLargeInput/coregex_IsMatch_64KB-4            107.0µ ± ∞ ¹     107.5µ ± ∞ ¹     +0.54% (p=0.016 n=5)
AhoCorasickManyPatterns/coregex_50_patterns-4           77.96n ± ∞ ¹     85.74n ± ∞ ¹     +9.98% (p=0.032 n=5)
MatchAnchoredLiteral/short_match-4                      6.883n ± ∞ ¹     7.187n ± ∞ ¹     +4.42% (p=0.008 n=5)
MatchAnchoredLiteral/no_match_suffix-4                  4.065n ± ∞ ¹     4.368n ± ∞ ¹     +7.45% (p=0.008 n=5)
AnchoredLiteralVsStdlib/coregex_short-4                 8.441n ± ∞ ¹     9.346n ± ∞ ¹    +10.72% (p=0.008 n=5)
AnchoredLiteralVsStdlib/coregex_no_match-4              5.929n ± ∞ ¹     6.559n ± ∞ ¹    +10.63% (p=0.008 n=5)

Full results available in workflow artifacts. CI runners have ~10-20% variance.
For accurate benchmarks, run locally: ./scripts/bench.sh --compare

kolkov added 2 commits March 23, 2026 11:56
… safe

selectLiteralStrategy blocked UseTeddy for any pattern with anchors, but
adjustForAnchors already wraps prefilter with WrapLineAnchor for (?m)^.
Added hasNonLineAnchors to allow UseTeddy when anchors are only (?m)^.

http_methods on macOS ARM64: 89ms -> <1ms (restored to v0.12.14 level).
Stdlib compat: 38/38 PASS.
@kolkov kolkov merged commit bc78fa7 into main Mar 23, 2026
9 checks passed
@kolkov kolkov deleted the hotfix/remove-dfa-multiline-downgrade branch March 23, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant