Repository navigation
perf(security): one-pass multi-literal prefilter for ScanSQL [W6-08] - #942
Conversation
…W6-08] Replace per-literal bytes.Contains checks with a single case-folding Aho-Corasick pass and alternation-aware CNF filters derived from each regex. Findings are byte-identical; fold buffer and pool removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task in 53s —— View job Review of PR #942: one-pass multi-literal prefilter for
|
Perf gate: PASS (shadow mode: report only, this check never fails)Base Runner CPU:
Rules: each arm runs 20 randomized code layouts ( Gated suite (GOGC=off, GOMAXPROCS=1)
A/A' control (base revision, disjoint layout seeds): 0 of 52 benchmarks moved more than 3%; 0 would have been flagged by the time rule; suite geomean +0.04%, p 0.640. Low power3 benchmark(s) have under 80% estimated power to be flagged on their own for a +5% slowdown (their spread across layouts is too wide for 20 layouts at the Benjamini-Hochberg level alpha/m = 0.000192). A slowdown below the last column usually goes unflagged there; instructions/op, allocs/op and the suite geomean still guard them.
Power is estimated with the normal approximation for the U test (Noether): power = Phi(ln(1+shift)/s * sqrt(K/2) * sqrt(3/pi) - z(1 - alpha/(2m))), with s the spread and K the layouts per arm. Instructions per operation (cmd/perfdriver)
Secondary metric: default GC, GOMAXPROCS=1 (informational)
Environmentbenchstat (primary metric, samples pooled across layouts: informational, the verdict uses the per-layout test) |
|
Claude finished @ajitpratap0's task in 33s —— View job Review of PR #942: one-pass multi-literal prefilter for
|
|
Claude finished @ajitpratap0's task in 22s —— View job Review of PR #942: one-pass multi-literal prefilter for
|
Summary
W6-08 (SEC-3).
Scanner.ScanSQLno longer runs ~70bytes.Containscalls per statement. One case-folding Aho-Corasick pass (62 literals, 309 states) sets a presence bitset; each of the 36 patterns checks an alternation/optional/assertion-aware CNF filter derived from its regex. The fold buffer and pool are removed. Findings are byte-identical; no exported API change.Also mechanically updates
wp_p_bypass_test.go(CNF iteration,nil->scanPrefilter{}), outside the brief's owned files but required to compile.Test Plan
go vet,go test -count=1 ./pkg/sql/security/...pass; Codex ran race (162s) andFuzzLiteralMatcher60s (877k execs): pass.task check,task test:cbinding,go test ./pkg/compatibility/..., staticcheck on pkg/sql/security: pass.task bench:abcould not run (disk full).Out of scope
Caching isASCII per view (the W6-01 follow-up) is deliberately not done: with alternation-aware filters the ClickHouse guard is rarely reached, and the identifier-tautology guard already computes isASCII once per view.
Breaking Changes
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2