Skip to content

perf(keywords): allocation-free case-insensitive keyword lookups [W2-07] - #944

Merged
ajitpratap0 merged 12 commits into
mainfrom
perf/w2-07-alloc-free-keywords-api
Nov 15, 2026
Merged

ajitpratap0 merged 12 commits into
mainfrom
perf/w2-07-alloc-free-keywords-api

Conversation

@ajitpratap0

@ajitpratap0 ajitpratap0 commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • New lookupFold helper (pkg/sql/keywords/lookup_fold.go): upper-cases pure-ASCII words up to 64 bytes into a stack buffer and looks up from there; any other input falls back to strings.ToUpper. Used by IsKeyword, GetKeywordType, IsReserved, GetKeyword, GetTokenType, IsCompoundKeywordStart and containsKeyword. Results are identical for every input (Unicode folds such as ſelect, invalid UTF-8, long words, case-sensitive instances).
  • Commit f681c44 perf(keywords): index already upper-case keys directly in lookupFold: the first amd64 matrix run 43702780432 (EPYC 9V74, base ed66d3b = old code + BenchmarkKeywordLookup, head c7ddd49 = the change) showed upper-case input +47% to +78% slower (about 15 ns -> 26 ns), because lookupFold always zeroed and filled a 64-byte buffer while strings.ToUpper returns s unchanged. lookupFold now scans first and indexes the map with s directly when it is already upper-case ASCII.
  • Adds BenchmarkKeywordLookup (commit 1 = baseline) and tests: differential oracle vs frozen copies of the old bodies, fuzz target, built-in-keys-fit-fast-path check, zero-alloc test (fails on the old code; 7 mutations M1-M7 each caught).
  • Consumers (formatter render, highlighter) see ~no change: their corpora already spell names in upper case. The gain shows on the direct benchmark.

Test Plan

  • task test:cbinding, go test ./pkg/compatibility/..., staticcheck on ./pkg/sql/keywords/...: pass.
  • go test -race on keywords, formatter, highlight, mcp: pass.
  • Fuzz 60s: pass (69k execs). Inlining: can inline lookupFold[...], string(buf[:len(s)]) does not escape.
  • Local M4 benchstat (n=6) vs old code: upper -12% to -27%, lower/mixed/miss -60% to -72%, long unchanged. Earlier local task bench:ab BASE=<commit1> (20 layouts, indicative, shared M4): lower/mixed/miss allocs 1 -> 0, B/op -> 0 for all six methods.
  • Mutation check (M1-M9; each caught by go test -run TestLookupFold ./pkg/sql/keywords/): M8 'a' <= c -> '`' <= c and M9 c <= 'z' -> c <= '{' are killed by the AddKeyword("A@B")/("A[B") keys and the "ab"/"a{b"inputs;c <= 'y'and'a' <= c->'b' <= c` also fail. Log: wave2a/W2-07/mutations.txt.
  • Gain evidence: no gated suite benchmark covers keyword lookups, so the CI gate cannot measure this target. The allocation gain is pinned by TestLookupFold_NoAllocs; with lookupFold temporarily replaced by m[strings.ToUpper(s)], go test -count=1 -run TestLookupFold_NoAllocs ./pkg/sql/keywords/ reports 46 FAIL lines (restored afterwards).
  • amd64 matrix, first run (superseded): run 43702780432 (EPYC 9V74, base ed66d3b, head c7ddd49) exposed the upper-case regression (+47% to +78%) fixed in f681c44. An earlier run 43282435198 (EPYC 7763, base 1f82800) had no base row for BenchmarkKeywordLookup, so it gave no A/B delta.
  • amd64 matrix, current (report-only, low power): run 43709819173 (EPYC 9V74, base ed66d3b, head f681c44), BenchmarkKeywordLookup rows only, 5 layouts per arm (smallest p 0.008):
    • upper: -8.7% to -16.5%, allocs 0 -> 0.
    • lower: -41.1% to -46.1%; mixed: -48.4% to -55.4%; miss: -52.0% to -54.5%; all allocs 1 -> 0, B/op -100%.
    • long (65-byte input strings.Repeat("x", 65), pkg/sql/keywords/lookup_bench_test.go:46, above keyBufLen, takes the strings.ToUpper fallback): +16.9% to +24.6% (about 157 ns -> 195 ns, p 0.008-0.095), allocs 1 -> 1. The 80 B/op is the 65-byte strings.ToUpper result rounded to the 80-byte size class.
    • The informational -40% target is met for lower/mixed/miss on amd64.
    • Other rows in that run's report are NOT attributable to this PR: head f681c44 contains merges of origin/main made after ed66d3b (e.g. the LintRule/L009, L018, L019, L021, L027 changes come from perf(linter): aliasing + 4 visitor rules onto Context.Nodes() [W6-05b] #953's intended shared-Nodes() trade-off). Only the BenchmarkKeywordLookup rows isolate this change.
  • CI perf gate: the merge-train gate will run on the final head and its result is appended before merge; the target benchmark is not in the gated suite.
  • AC-STD: task check, task test:cbinding, compatibility and staticcheck passed on 3dcfe7d; f681c44 changes only lookupFold and passes go test ./pkg/sql/keywords/.

Breaking Changes

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2

Final gate before merge (merge train)

The perf gate ran on the final head 5a695728e596 merged with current main: ## Perf gate: PASS (shadow mode: report only, this check never fails), report #944 (comment). This result replaces any earlier gate numbers in this description.

ajitpratap0 and others added 2 commits November 3, 2026 22:40
lookupFold upper-cases pure-ASCII words up to 64 bytes into a stack buffer;
other input falls back to strings.ToUpper. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
gosqlx-website Ready Ready Preview Nov 15, 2026 2:59pm UTC

@github-actions github-actions Bot added documentation Improvements or additions to documentation performance dialects labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 20s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good, with a few nits. I found no blocking issues.

I read the production diff in full. I did not run the tests or benchmarks. The numbers below are from your PR description.

Correctness

  • lookupFold (pkg/sql/keywords/lookup_fold.go) matches strings.ToUpper for every input class.
    • A pure-ASCII word of 64 bytes or fewer is upper-cased into a stack buffer.
    • Any byte at or above utf8.RuneSelf breaks out of the loop and falls back to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
    • Words over 64 bytes also fall back.
    • The i == len(s) check after the loop is correct, including for the empty string.
  • m[string(buf[:n])] is the map-index form the compiler optimises to avoid allocating. Your escape-analysis note confirms it.
  • The case-sensitive paths are unchanged. GetKeyword still upper-cases unconditionally, as before, regardless of ignoreCase.
  • GetKeywordType and GetTokenType now return TokenTypeWord explicitly on a miss in the folded branch. That is equivalent to the old behaviour.
  • A generic helper with V any should be fine here. Keyword is a small struct, so copying it by value is cheap.

Performance

  • The 64-byte buffer is zero-initialised on every call. For typical 3–10 byte keywords that is a small fixed cost (about one 64-byte store). It is still far cheaper than an allocation, and the "upper" case still improves by 6–29%.
  • The IsKeyword/long +4.75% result (p=0.007) is almost certainly noise or layout effects. The len > 64 path is the same code as before, except for the extra length compare. I agree with your reading.

Tests

  • The differential oracle against frozen copies of the old bodies, the fuzz target, the "built-in keys fit" pin and the zero-alloc test are the right set. The mutation checks (M1–M7) are a nice touch.
  • One suggestion: add explicit cases at exactly 63, 64 and 65 bytes if they are not already there. That is where the <= boundary could regress. Skip this if the oracle already generates them.

Nits

  • In categories.go, the new line "Pure-ASCII words up to 64 bytes…" sits directly under the first doc line of GetKeywordType. The comment is a single run-on paragraph with no sentence break, so consider separating it with a // blank line.
  • keyBufLen's comment says "longest is 20 bytes on origin/main". That will go stale as keywords are added. The pinning test already enforces the invariant, so the number could be dropped.
  • CHANGELOG, README and doc.go are updated. The PR description's "CI perf gate" comment is still to be filled in. Please make sure the amd64 gate result is posted before merge, as CLAUDE.md requires.

No security concerns. The change is pure lookup logic with no new inputs or unsafe code.
· branch perf/w2-07-alloc-free-keywords-api

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Perf gate: PASS (shadow mode: report only, this check never fails)

Base 6d35301bc7fa, head 2f9163ec4674. 20 interleaved rounds, 20 randomized code layouts per arm (-randlayout seeds 437272745992..437272746011; A/A' 437272746012..437272746031), benchtime 100ms, -cpu 1, GOMEMLIMIT 64MiB, pinned to CPU 3 (SMT siblings 2-3) with taskset. adaptive layouts: budget 600s, cap 200; 23 planned benchmarks extended to up to 200 layouts, 4 line warm-ups, in 2 stage(s), 561s, done.

Runner CPU: AMD EPYC 7763 64-Core Processor (x86_64). Base and head ran interleaved in this job, so the tables show their ratios only; absolute timings (raw files in the artifact) hold for this CPU and this job alone and are never compared across jobs.

  • no gated metric moved past its threshold

Rules: each arm runs 20 randomized code layouts (-ldflags=-randlayout); time regresses at >= +3% when significant at a false discovery rate of 0.01 over the suite (Benjamini-Hochberg on exact Mann-Whitney U p-values of the per-layout medians, so a regression must hold across layouts, not within one binary), or a suite geomean >= +1.5% (per-layout suite geomeans, same test); allocs/op must not increase; B/op must not rise more than 2%; instructions/op must not rise more than 1.5%. The A/A' control runs the base revision under a disjoint set of layout seeds; when more than 10% of benchmarks move over 3% in it, the run is noisy: re-run once, then inconclusive (neutral). Benchmarks under 80% estimated power for a lone +5% slowdown at alpha/m get extra layouts (adaptive, budget-limited); plans size to 90% estimated power, and time is judged over all of each benchmark's layouts.

Stage 1 used 20 layouts per arm; 23 benchmark(s) received planned adaptive extensions, with 4 warm-up benchmark(s) and 0 unclassified benchmark(s), to up to 200 layouts per arm. Only primary time uses those extra layouts; every other rule uses stage-1 data.

Gated suite (GOGC=off, GOMAXPROCS=1)

benchmark time p A/A' spread K power B/op allocs/op status
ParseE2E/simple_select +0.32% 0.244 +1.00% 0.91% 58 100% +0.00% 3 → 3 ok
ParseE2E/select_where +0.65% 0.084 +0.97% 1.04% 28 89% +0.00% 16 → 16 ok
ParseE2E/join +0.35% 0.394 -0.10% 0.77% 20 90% +0.00% 15 → 15 ok
ParseE2E/aggregate +0.33% 0.570 +0.76% 2.72% 58 96% +0.00% 13 → 13 ok
ParseE2E/subquery +0.41% 0.569 +0.82% 2.72% 30 94% +0.00% 10 → 10 ok
ParseE2E/cte +0.98% 0.117 +0.43% 1.93% 20 87% +0.00% 16 → 16 ok
ParseE2E/window +0.35% 0.457 +0.51% 1.64% 20 87% +0.00% 9 → 9 ok
ParseE2E/complex -0.30% 0.585 +0.22% 1.93% 34 96% +0.00% 43 → 43 ok
ParseE2E/insert +1.04% 0.093 +0.23% 2.23% 20 88% +0.00% 17 → 17 ok
ParseE2E/update +0.44% 0.185 +0.36% 0.54% 20 91% +0.00% 13 → 13 ok
ParseE2E/delete +1.71% 0.011 +0.82% 1.50% 20 81% +0.00% 5 → 5 ok
ParseRW/postgresql/medium +0.19% 0.490 +0.76% 1.71% 45 100% +0.00% 583 → 583 ok
ParseRW/mysql/medium -0.17% 0.695 -0.27% 1.16% 20 89% +0.00% 334 → 334 ok
ParseRW/mariadb/medium +0.13% 0.820 +0.08% 0.94% 20 92% +0.00% 470 → 470 ok
ParseRW/sqlserver/medium -0.21% 0.698 -0.01% 1.74% 20 86% +0.00% 853 → 853 ok
ParseRW/oracle/medium -0.12% 0.678 -0.02% 1.52% 20 91% +0.00% 962 → 962 ok
ParseRW/sqlite/medium -0.29% 0.693 +0.06% 1.78% 27 92% +0.00% 318 → 318 ok
ParseRW/snowflake/medium +0.48% 0.186 +0.51% 1.23% 45 99% +0.00% 630 → 630 ok
ParseRW/clickhouse/medium +0.62% 0.225 +1.26% 1.87% 28 93% +0.00% 336 → 336 ok
ParseFresh/simple_select +1.04% 0.021 +0.63% 1.04% 20 93% +0.00% 4 → 4 ok
ParseFresh/join +1.38% <0.001 +0.37% 0.65% 20 93% +0.00% 16 → 16 ok
ParseFresh/complex +0.11% 0.756 -0.95% 1.70% 20 86% +0.00% 44 → 44 ok
ParseFresh/insert +1.09% 0.002 +0.37% 1.10% 20 94% +0.00% 18 → 18 ok
ParseFresh/update +0.00% 1.000 +0.07% 1.54% 20 93% +0.00% 14 → 14 ok
ParseFresh/delete +0.15% 0.839 +0.56% 0.75% 20 85% +0.00% 6 → 6 ok
PoolGetPut/serial -0.10% 0.720 -0.10% 1.50% 35 94% +0.00% 0 → 0 ok
Tokenize/scratch/join -0.14% 0.771 -0.44% 1.95% 38 99% +0.00% 0 → 0 ok
Tokenize/scratch/complex +0.84% 0.205 -0.53% 2.77% 35 95% +0.00% 0 → 0 ok
Tokenize/scratch/insert -0.17% 0.807 -0.32% 3.07% 38 93% +0.00% 0 → 0 ok
Normalize/simple_select +0.58% 0.387 +0.36% 1.40% 20 88% +0.00% 5 → 5 ok
Normalize/join +0.37% 0.194 +0.18% 0.56% 20 94% +0.00% 21 → 21 ok
Normalize/complex +0.14% 0.808 +0.06% 1.14% 20 94% +0.00% 62 → 62 ok
TransformParse/simple_select +0.25% 0.562 +0.13% 1.42% 39 90% +0.00% 3 → 3 ok
TransformParse/join -0.67% 0.229 -0.09% 1.80% 20 93% +0.00% 15 → 15 ok
TransformParse/complex -0.26% 0.646 +0.09% 1.17% 20 90% +0.00% 43 → 43 ok
LintParallel/rules -0.03% 0.970 -0.07% 2.52% 44 88% -0.00% 68934 → 68934 ok
LintParallel/lint -0.26% 0.640 -0.38% 3.02% 20 87% -0.00% 126680 → 126680 ok
LintRW/postgresql -0.21% 0.307 -0.37% 0.93% 33 100% -0.00% 14130 → 14130 ok
LintRW/mysql +0.10% 0.841 -0.06% 0.95% 20 90% -0.00% 17457 → 17457 ok
LintRW/mariadb -0.13% 0.820 -0.40% 2.61% 20 84% -0.00% 15755 → 15755 ok
LintRW/sqlserver -0.26% 0.398 -0.83% 0.87% 20 93% +0.00% 13871 → 13871 ok
LintRW/oracle -0.11% 0.904 +0.75% 0.83% 20 91% -0.00% 16857 → 16857 ok
LintRW/sqlite -0.80% 0.142 -0.78% 3.14% 26 92% +0.00% 15739 → 15739 ok
LintRW/snowflake -0.40% 0.366 +0.23% 2.00% 28 93% +0.00% 15204 → 15204 ok
LintRW/clickhouse -0.63% 0.390 -0.19% 2.03% 33 92% -0.00% 17660 → 17660 ok
LintRule/L007 +0.23% 0.339 -0.40% 2.29% 200 100% +0.00% 1194 → 1194 ok
LintRule/L010 -0.04% 0.348 -0.02% 5.31% 200 99% +0.00% 0 → 0 ok
ParseError/syntax_mid/parse +0.95% <0.001 +0.11% 1.20% 60 100% +0.00% 11 → 11 ok
ParseError/syntax_mid/validate +0.80% 0.144 +0.32% 1.35% 20 91% +0.00% 11 → 11 ok
ParseError/syntax_end/parse -0.48% 0.151 -0.57% 0.61% 20 94% +0.00% 14 → 14 ok
ParseError/syntax_end/validate -0.24% 0.696 +0.24% 3.13% 60 92% +0.00% 14 → 14 ok
ParseError/tokenize/parse +0.54% 0.565 -1.00% 3.00% 20 80% +0.00% 4 → 4 ok
ParseError/tokenize/validate -0.19% 0.776 -0.89% 2.12% 20 87% +0.00% 21 → 21 ok
ParseError/long_prefix/parse -0.29% 0.735 -0.62% 1.39% 20 82% +0.00% 213 → 213 ok
ParseError/long_prefix/validate +0.20% 0.706 -0.56% 2.95% 36 91% +0.00% 213 → 213 ok
WASMBridge/parse/small +0.54% 0.264 +0.25% 2.01% 26 96% +0.00% 8 → 8 ok
WASMBridge/parse/medium +0.23% 0.659 -0.37% 1.52% 20 92% +0.00% 38 → 38 ok
WASMBridge/parse/large +0.40% 0.277 +0.02% 1.37% 20 89% +0.00% 522 → 522 ok
WASMBridge/lint/small -0.45% 0.365 +0.31% 1.71% 20 89% +0.00% 33 → 33 ok
WASMBridge/lint/medium +1.01% 0.114 +0.56% 1.67% 20 88% +0.00% 100 → 100 ok
WASMBridge/lint/large +1.08% 0.152 +0.67% 2.27% 26 89% -0.00% 1031 → 1031 ok
DetectDialect/empty +0.00% 0.896 +0.54% 18.35% 200 55% +0.00% 0 → 0 ok
DetectDialect/generic +0.39% 0.140 +0.05% 0.78% 20 90% +0.00% 0 → 0 ok
DetectDialect/postgresql -0.05% 0.829 -0.18% 0.21% 20 90% +0.00% 0 → 0 ok
DetectDialect/mysql +1.08% 0.060 +0.35% 1.95% 20 91% +0.00% 0 → 0 ok
DetectDialect/sqlserver +0.09% 0.841 -0.23% 1.66% 20 92% +0.00% 0 → 0 ok
DetectDialect/oracle +0.14% 0.372 +0.11% 0.38% 20 93% +0.00% 0 → 0 ok
DetectDialect/snowflake +0.13% 0.588 +0.04% 0.44% 20 86% +0.00% 0 → 0 ok
DetectDialect/mariadb +0.72% 0.053 +0.16% 0.77% 20 92% +0.00% 0 → 0 ok
DetectDialect/mixed +0.07% 0.685 +0.02% 0.28% 20 89% +0.00% 0 → 0 ok
DetectDialect/large_64KB +0.52% 0.024 +0.07% 0.57% 20 95% +0.00% 0 → 0 ok
geomean +0.27% 0.149 +0.08%

time and A/A' are Hodges-Lehmann shifts over the per-layout medians. spread: the base arm's robust standard deviation across its layouts (1.4826 x MAD, relative), i.e. how much this benchmark moves between builds that differ only in function placement, plus run-to-run noise; K is layouts per arm. Power uses Noether's normal approximation with the effect size taken from the data: AUC = P(head layout slower than base layout) under a +5% shift over pooled within-arm residuals, a conservative estimate. Plans size to 90% estimated power while the stopping target remains 80%.

A/A' control (base revision, disjoint layout seeds): 0 of 71 benchmarks moved more than 3%; 0 would have been flagged by the time rule; suite geomean +0.08%, p 0.183.

Low power

Adaptive layouts: 23 benchmark(s) extended from 20 to up to 200 layouts per arm (done); 4 warm-up benchmark(s), 0 unclassified benchmark(s) received extra measurements.

1 benchmark(s) have under 80% estimated power to be flagged on their own for a +5% slowdown at the Benjamini-Hochberg level alpha/m = 0.000141. Instructions/op, allocs/op and the stage-1 suite geomean still guard them.

benchmark K power at +5% slowdown caught 80% of the time reason
DetectDialect/empty 200 55% +10.9% needs more than 200 layouts per arm (cap)

Power is estimated by Noether's normal approximation using the empirical AUC of pooled within-arm log residuals, excluding self-pairs and giving half credit for ties.

Instructions per operation (cmd/perfdriver)

case instructions/op status
e2e/aggregate -0.03% ok
e2e/complex +0.02% ok
e2e/cte +0.02% ok
e2e/delete -0.02% ok
e2e/insert +0.04% ok
e2e/join +0.02% ok
e2e/select_where +0.04% ok
e2e/simple_select +0.20% ok
e2e/subquery -0.08% ok
e2e/update -0.02% ok
e2e/window -0.11% ok
rw/postgresql/medium +0.11% ok
Secondary metric: default GC, GOMAXPROCS=1 (informational)
benchmark time p
ParseE2E/simple_select +0.73% 0.520
ParseE2E/select_where +0.33% 0.705
ParseE2E/join +0.71% 0.496
ParseE2E/aggregate -0.15% 0.734
ParseE2E/subquery -0.20% 0.650
ParseE2E/cte +1.51% 0.049
ParseE2E/window -0.37% 0.910
ParseE2E/complex -0.25% 0.631
ParseE2E/insert +0.22% 0.623
ParseE2E/update +1.26% 0.173
ParseE2E/delete -0.43% 0.472
ParseRW/postgresql/medium -0.15% 0.739
ParseRW/mysql/medium +0.23% 0.912
ParseRW/mariadb/medium +0.56% 0.597
ParseRW/sqlserver/medium +0.48% 0.393
ParseRW/oracle/medium -0.06% 0.853
ParseRW/sqlite/medium +0.62% 0.393
ParseRW/snowflake/medium +1.23% 0.190
ParseRW/clickhouse/medium -0.09% 0.971
ParseFresh/simple_select +0.56% 0.290
ParseFresh/join +1.11% 0.038
ParseFresh/complex +0.25% 0.597
ParseFresh/insert +0.43% 0.450
ParseFresh/update +1.06% 0.008
ParseFresh/delete +0.48% 0.257
PoolGetPut/serial -2.05% 0.089
Tokenize/scratch/join +1.48% 0.226
Tokenize/scratch/complex +2.26% 0.043
Tokenize/scratch/insert -0.43% 0.853
Normalize/simple_select +0.02% 1.000
Normalize/join -0.31% 0.529
Normalize/complex -0.19% 0.684
TransformParse/simple_select +1.64% 0.049
TransformParse/join +0.60% 0.631
TransformParse/complex +0.58% 0.384
LintParallel/rules -0.73% 0.481
LintParallel/lint -0.15% 0.971
LintRW/postgresql -1.42% 0.043
LintRW/mysql -0.32% 0.684
LintRW/mariadb -0.23% 0.436
LintRW/sqlserver -0.06% 0.684
LintRW/oracle -0.26% 0.579
LintRW/sqlite -0.39% 0.684
LintRW/snowflake +0.86% 0.353
LintRW/clickhouse -0.74% 0.393
LintRule/L007 -1.90% 0.165
LintRule/L010 -0.37% 0.406
ParseError/syntax_mid/parse -0.16% 0.912
ParseError/syntax_mid/validate +0.81% 0.450
ParseError/syntax_end/parse +0.92% 0.121
ParseError/syntax_end/validate -0.36% 0.762
ParseError/tokenize/parse +1.03% 0.393
ParseError/tokenize/validate -0.42% 0.384
ParseError/long_prefix/parse +2.63% 0.015
ParseError/long_prefix/validate +0.90% 0.105
WASMBridge/parse/small -0.20% 0.762
WASMBridge/parse/medium +1.10% 0.143
WASMBridge/parse/large +0.74% 0.143
WASMBridge/lint/small -0.54% 0.307
WASMBridge/lint/medium -0.27% 0.853
WASMBridge/lint/large +0.12% 0.739
DetectDialect/empty -0.06% 0.850
DetectDialect/generic -0.00% 1.000
DetectDialect/postgresql +0.08% 0.677
DetectDialect/mysql +0.12% 0.853
DetectDialect/sqlserver -0.68% 0.406
DetectDialect/oracle +0.03% 0.910
DetectDialect/snowflake +0.12% 0.579
DetectDialect/mariadb +0.21% 0.426
DetectDialect/mixed +0.21% 0.450
DetectDialect/large_64KB -0.12% 0.579
geomean +0.20%
Environment
date:        2026-11-15T15:02:25Z
base:        6d35301bc7fab632b1f923ee338e38f662ad5524
head:        working tree of 2f9163ec4674daeeb955f93c13232780b92d26c6
cpu model:   AMD EPYC 7763 64-Core Processor (x86_64)
go:          go version go1.26.9 linux/amd64
kernel:      Linux 7.0.0-1017-azure x86_64
layouts:     20 per arm, -ldflags=-randlayout seeds 437272745992..437272746011 (base, head), 437272746012..437272746031 (A/A')
pinning:     pinned to CPU 3 (SMT siblings 2-3) with taskset
gcoff env:   GOGC=off GOMEMLIMIT=64MiB
clocksource: tsc
load:        6.96, 3.55, 1.42
instr count: cachegrind
perf probe:  Error: No supported events found. The instructions:u event is not supported. 

Architecture:                            x86_64
CPU(s):                                  4
Model name:                              AMD EPYC 7763 64-Core Processor
Thread(s) per core:                      2
Core(s) per socket:                      2
Socket(s):                               1
Hypervisor vendor:                       Microsoft
L1d cache:                               64 KiB (2 instances)
L1i cache:                               64 KiB (2 instances)
L2 cache:                                1 MiB (2 instances)
L3 cache:                                32 MiB (1 instance)
extension:   2 stage(s), layouts 21..230, seeds 437272746032..437272746241, 561s, done
benchstat (primary metric, samples pooled across layouts: informational, the verdict uses the per-layout test)
goos: linux
goarch: amd64
pkg: github.com/ajitpratap0/GoSQLX/pkg/fingerprint
cpu: AMD EPYC 7763 64-Core Processor                
                        │    base     │                head                │
                        │   sec/op    │   sec/op     vs base               │
Normalize/simple_select   2.227µ ± 1%   2.245µ ± 1%       ~ (p=0.387 n=20)
Normalize/join            6.978µ ± 1%   7.046µ ± 1%       ~ (p=0.194 n=20)
Normalize/complex         19.26µ ± 1%   19.32µ ± 1%       ~ (p=0.805 n=20)
geomean                   6.689µ        6.737µ       +0.72%

                        │     base     │                 head                  │
                        │     B/op     │     B/op      vs base                 │
Normalize/simple_select     784.0 ± 0%     784.0 ± 0%       ~ (p=1.000 n=20) ¹
Normalize/join            2.164Ki ± 0%   2.164Ki ± 0%       ~ (p=1.000 n=20) ¹
Normalize/complex         5.977Ki ± 0%   5.977Ki ± 0%       ~ (p=1.000 n=20) ¹
geomean                   2.147Ki        2.147Ki       +0.00%
¹ all samples are equal

                        │    base    │                head                 │
                        │ allocs/op  │ allocs/op   vs base                 │
Normalize/simple_select   5.000 ± 0%   5.000 ± 0%       ~ (p=1.000 n=20) ¹
Normalize/join            21.00 ± 0%   21.00 ± 0%       ~ (p=1.000 n=20) ¹
Normalize/complex         62.00 ± 0%   62.00 ± 0%       ~ (p=1.000 n=20) ¹
geomean                   18.67        18.67       +0.00%
¹ all samples are equal

pkg: github.com/ajitpratap0/GoSQLX/pkg/gosqlx
                                │    base     │                head                │
                                │   sec/op    │   sec/op     vs base               │
ParseE2E/simple_select            1.553µ ± 1%   1.568µ ± 3%       ~ (p=0.087 n=20)
ParseE2E/select_where             3.411µ ± 1%   3.438µ ± 1%       ~ (p=0.082 n=20)
ParseE2E/join                     4.647µ ± 1%   4.659µ ± 1%       ~ (p=0.394 n=20)
ParseE2E/aggregate                3.351µ ± 2%   3.428µ ± 3%       ~ (p=0.035 n=20)
ParseE2E/subquery                 2.942µ ± 3%   2.967µ ± 3%       ~ (p=0.441 n=20)
ParseE2E/cte                      4.467µ ± 1%   4.509µ ± 2%       ~ (p=0.116 n=20)
ParseE2E/window                   2.851µ ± 1%   2.846µ ± 2%       ~ (p=0.457 n=20)
ParseE2E/complex                  12.01µ ± 2%   11.99µ ± 3%       ~ (p=0.693 n=20)
ParseE2E/insert                   2.161µ ± 2%   2.194µ ± 1%       ~ (p=0.092 n=20)
ParseE2E/update                   1.928µ ± 0%   1.934µ ± 1%       ~ (p=0.185 n=20)
ParseE2E/delete                   1.239µ ± 1%   1.253µ ± 2%  +1.13% (p=0.009 n=20)
ParseRW/postgresql/medium         169.4µ ± 1%   169.7µ ± 1%       ~ (p=0.341 n=20)
ParseRW/mysql/medium              94.29µ ± 1%   94.10µ ± 1%       ~ (p=0.693 n=20)
ParseRW/mariadb/medium            135.1µ ± 1%   134.9µ ± 1%       ~ (p=0.820 n=20)
ParseRW/sqlserver/medium          273.7µ ± 1%   272.0µ ± 1%       ~ (p=0.698 n=20)
ParseRW/oracle/medium             322.4µ ± 1%   321.5µ ± 0%       ~ (p=0.678 n=20)
ParseRW/sqlite/medium             72.23µ ± 2%   72.10µ ± 2%       ~ (p=0.989 n=20)
ParseRW/snowflake/medium          184.5µ ± 1%   185.2µ ± 4%       ~ (p=0.820 n=20)
ParseRW/clickhouse/medium         84.43µ ± 3%   85.46µ ± 2%       ~ (p=0.664 n=20)
ParseFresh/simple_select          2.842µ ± 1%   2.865µ ± 2%       ~ (p=0.019 n=20)
ParseFresh/join                   6.385µ ± 0%   6.461µ ± 2%  +1.20% (p=0.000 n=20)
ParseFresh/complex                15.55µ ± 1%   15.58µ ± 1%       ~ (p=0.753 n=20)
ParseFresh/insert                 3.773µ ± 1%   3.834µ ± 1%  +1.62% (p=0.002 n=20)
ParseFresh/update                 3.559µ ± 1%   3.553µ ± 1%       ~ (p=1.000 n=20)
ParseFresh/delete                 2.756µ ± 1%   2.764µ ± 1%       ~ (p=0.836 n=20)
PoolGetPut/serial                 66.97n ± 7%   67.49n ± 1%       ~ (p=1.000 n=20)
ParseError/syntax_mid/parse       2.343µ ± 1%   2.366µ ± 2%       ~ (p=0.039 n=20)
ParseError/syntax_mid/validate    2.143µ ± 1%   2.161µ ± 2%       ~ (p=0.143 n=20)
ParseError/syntax_end/parse       2.808µ ± 0%   2.791µ ± 1%       ~ (p=0.151 n=20)
ParseError/syntax_end/validate    2.610µ ± 4%   2.627µ ± 1%       ~ (p=0.180 n=20)
ParseError/tokenize/parse         928.5n ± 2%   926.9n ± 2%       ~ (p=0.565 n=20)
ParseError/tokenize/validate      2.829µ ± 1%   2.813µ ± 1%       ~ (p=0.774 n=20)
ParseError/long_prefix/parse      56.91µ ± 1%   56.69µ ± 1%       ~ (p=0.733 n=20)
ParseError/long_prefix/validate   55.38µ ± 1%   55.36µ ± 3%       ~ (p=0.799 n=20)
geomean                           8.129µ        8.163µ       +0.43%

                                │     base     │                head                 │
                                │     B/s      │     B/s       vs base               │
ParseE2E/simple_select            15.97Mi ± 1%   15.81Mi ± 3%       ~ (p=0.080 n=20)
ParseE2E/select_where             28.80Mi ± 1%   28.58Mi ± 1%       ~ (p=0.090 n=20)
ParseE2E/join                     25.86Mi ± 1%   25.79Mi ± 1%       ~ (p=0.402 n=20)
ParseE2E/aggregate                23.91Mi ± 2%   23.37Mi ± 3%       ~ (p=0.033 n=20)
ParseE2E/subquery                 26.59Mi ± 3%   26.36Mi ± 3%       ~ (p=0.433 n=20)
ParseE2E/cte                      26.48Mi ± 1%   26.23Mi ± 2%       ~ (p=0.110 n=20)
ParseE2E/window                   31.44Mi ± 1%   31.50Mi ± 2%       ~ (p=0.457 n=20)
ParseE2E/complex                  30.03Mi ± 2%   30.08Mi ± 3%       ~ (p=0.673 n=20)
ParseE2E/insert                   33.55Mi ± 2%   33.04Mi ± 1%       ~ (p=0.090 n=20)
ParseE2E/update                   27.21Mi ± 0%   27.11Mi ± 1%       ~ (p=0.180 n=20)
ParseE2E/delete                   40.03Mi ± 1%   39.58Mi ± 2%       ~ (p=0.010 n=20)
ParseRW/postgresql/medium         21.19Mi ± 1%   21.15Mi ± 1%       ~ (p=0.337 n=20)
ParseRW/mysql/medium              28.71Mi ± 1%   28.76Mi ± 1%       ~ (p=0.693 n=20)
ParseRW/mariadb/medium            26.25Mi ± 1%   26.28Mi ± 1%       ~ (p=0.794 n=20)
ParseRW/sqlserver/medium          24.31Mi ± 1%   24.46Mi ± 1%       ~ (p=0.693 n=20)
ParseRW/oracle/medium             26.00Mi ± 1%   26.07Mi ± 0%       ~ (p=0.683 n=20)
ParseRW/sqlite/medium             28.60Mi ± 2%   28.65Mi ± 2%       ~ (p=1.000 n=20)
ParseRW/snowflake/medium          27.56Mi ± 1%   27.45Mi ± 4%       ~ (p=0.815 n=20)
ParseRW/clickhouse/medium         26.69Mi ± 3%   26.36Mi ± 3%       ~ (p=0.683 n=20)
ParseError/syntax_mid/parse       19.54Mi ± 1%   19.35Mi ± 2%       ~ (p=0.042 n=20)
ParseError/syntax_mid/validate    21.37Mi ± 1%   21.18Mi ± 2%       ~ (p=0.144 n=20)
ParseError/syntax_end/parse       13.24Mi ± 0%   13.33Mi ± 1%       ~ (p=0.136 n=20)
ParseError/syntax_end/validate    14.25Mi ± 4%   14.16Mi ± 1%       ~ (p=0.180 n=20)
ParseError/tokenize/parse         47.25Mi ± 2%   47.33Mi ± 2%       ~ (p=0.560 n=20)
ParseError/tokenize/validate      15.51Mi ± 1%   15.60Mi ± 1%       ~ (p=0.774 n=20)
ParseError/long_prefix/parse      40.58Mi ± 1%   40.74Mi ± 1%       ~ (p=0.733 n=20)
ParseError/long_prefix/validate   41.71Mi ± 1%   41.72Mi ± 3%       ~ (p=0.805 n=20)
geomean                           25.89Mi        25.80Mi       -0.36%

                                │      base      │                 head                  │
                                │      B/op      │     B/op      vs base                 │
ParseE2E/simple_select              704.0 ± 0%       704.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/select_where             1.477Ki ± 0%     1.477Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/join                     1.789Ki ± 0%     1.789Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/aggregate                1.719Ki ± 0%     1.719Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/subquery                 1.609Ki ± 0%     1.609Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/cte                      2.070Ki ± 0%     2.070Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/window                   1.234Ki ± 0%     1.234Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/complex                  4.885Ki ± 0%     4.885Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/insert                     824.0 ± 0%       824.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/update                     736.0 ± 0%       736.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/delete                     400.0 ± 0%       400.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/postgresql/medium         64.43Ki ± 0%     64.43Ki ± 0%       ~ (p=0.929 n=20)
ParseRW/mysql/medium              40.70Ki ± 0%     40.70Ki ± 0%       ~ (p=1.000 n=20)
ParseRW/mariadb/medium            58.53Ki ± 0%     58.53Ki ± 0%       ~ (p=0.329 n=20)
ParseRW/sqlserver/medium          81.26Ki ± 0%     81.26Ki ± 0%       ~ (p=0.654 n=20)
ParseRW/oracle/medium             100.9Ki ± 0%     100.9Ki ± 0%       ~ (p=0.512 n=20)
ParseRW/sqlite/medium             37.30Ki ± 0%     37.30Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/snowflake/medium          73.29Ki ± 0%     73.29Ki ± 0%       ~ (p=1.000 n=20)
ParseRW/clickhouse/medium         32.99Ki ± 0%     32.99Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/simple_select            784.0 ± 0%       784.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/join                   1.867Ki ± 0%     1.867Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/complex                4.961Ki ± 0%     4.961Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/insert                   904.0 ± 0%       904.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/update                   816.0 ± 0%       816.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/delete                   480.0 ± 0%       480.0 ± 0%       ~ (p=1.000 n=20) ¹
PoolGetPut/serial                   0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_mid/parse         552.0 ± 0%       552.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_mid/validate      552.0 ± 0%       552.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_end/parse       1.320Ki ± 0%     1.320Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_end/validate    1.320Ki ± 0%     1.320Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseError/tokenize/parse           272.0 ± 0%       272.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/tokenize/validate      1.758Ki ± 0%     1.758Ki ± 0%       ~ (p=1.000 n=20) ¹
ParseError/long_prefix/parse      17.14Ki ± 0%     17.14Ki ± 0%       ~ (p=0.181 n=20)
ParseError/long_prefix/validate   17.07Ki ± 0%     17.07Ki ± 0%       ~ (p=1.000 n=20) ¹
geomean                                        ²                 +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                │     base     │                head                 │
                                │  allocs/op   │ allocs/op   vs base                 │
ParseE2E/simple_select            3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/select_where             16.00 ± 0%     16.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/join                     15.00 ± 0%     15.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/aggregate                13.00 ± 0%     13.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/subquery                 10.00 ± 0%     10.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/cte                      16.00 ± 0%     16.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/window                   9.000 ± 0%     9.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/complex                  43.00 ± 0%     43.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/insert                   17.00 ± 0%     17.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/update                   13.00 ± 0%     13.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseE2E/delete                   5.000 ± 0%     5.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/postgresql/medium         583.0 ± 0%     583.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/mysql/medium              334.0 ± 0%     334.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/mariadb/medium            470.0 ± 0%     470.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/sqlserver/medium          853.0 ± 0%     853.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/oracle/medium             962.0 ± 0%     962.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/sqlite/medium             318.0 ± 0%     318.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/snowflake/medium          630.0 ± 0%     630.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseRW/clickhouse/medium         336.0 ± 0%     336.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/simple_select          4.000 ± 0%     4.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/join                   16.00 ± 0%     16.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/complex                44.00 ± 0%     44.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/insert                 18.00 ± 0%     18.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/update                 14.00 ± 0%     14.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseFresh/delete                 6.000 ± 0%     6.000 ± 0%       ~ (p=1.000 n=20) ¹
PoolGetPut/serial                 0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_mid/parse       11.00 ± 0%     11.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_mid/validate    11.00 ± 0%     11.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_end/parse       14.00 ± 0%     14.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/syntax_end/validate    14.00 ± 0%     14.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/tokenize/parse         4.000 ± 0%     4.000 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/tokenize/validate      21.00 ± 0%     21.00 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/long_prefix/parse      213.0 ± 0%     213.0 ± 0%       ~ (p=1.000 n=20) ¹
ParseError/long_prefix/validate   213.0 ± 0%     213.0 ± 0%       ~ (p=1.000 n=20) ¹
geomean                                      ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                          │    base     │                head                │
                          │  sec/stmt   │  sec/stmt    vs base               │
ParseRW/postgresql/medium   14.11µ ± 1%   14.14µ ± 1%       ~ (p=0.341 n=20)
ParseRW/mysql/medium        11.79µ ± 1%   11.76µ ± 1%       ~ (p=0.683 n=20)
ParseRW/mariadb/medium      15.01µ ± 1%   14.99µ ± 1%       ~ (p=0.805 n=20)
ParseRW/sqlserver/medium    13.04µ ± 1%   12.95µ ± 1%       ~ (p=0.703 n=20)
ParseRW/oracle/medium       13.44µ ± 1%   13.40µ ± 0%       ~ (p=0.673 n=20)
ParseRW/sqlite/medium       12.04µ ± 2%   12.02µ ± 2%       ~ (p=0.989 n=20)
ParseRW/snowflake/medium    14.19µ ± 1%   14.25µ ± 4%       ~ (p=0.815 n=20)
ParseRW/clickhouse/medium   12.06µ ± 3%   12.21µ ± 2%       ~ (p=0.664 n=20)
geomean                     13.16µ        13.17µ       +0.04%

pkg: github.com/ajitpratap0/GoSQLX/pkg/linter
                   │     base     │                head                │
                   │    sec/op    │   sec/op     vs base               │
LintParallel/rules   20.47m ±  4%   20.58m ± 3%       ~ (p=0.314 n=20)
LintParallel/lint    38.74m ±  2%   38.43m ± 1%       ~ (p=0.640 n=20)
LintRW/postgresql    5.047m ±  1%   5.023m ± 1%       ~ (p=0.040 n=20)
LintRW/mysql         5.420m ±  1%   5.429m ± 1%       ~ (p=0.841 n=20)
LintRW/mariadb       4.940m ±  2%   4.915m ± 2%       ~ (p=0.820 n=20)
LintRW/sqlserver     4.674m ±  1%   4.649m ± 1%       ~ (p=0.398 n=20)
LintRW/oracle        5.565m ±  1%   5.573m ± 2%       ~ (p=0.904 n=20)
LintRW/sqlite        4.537m ±  2%   4.475m ± 3%       ~ (p=0.289 n=20)
LintRW/snowflake     4.770m ±  3%   4.739m ± 3%       ~ (p=0.383 n=20)
LintRW/clickhouse    5.350m ±  4%   5.173m ± 3%       ~ (p=0.277 n=20)
LintRule/L007        2.753m ±  2%   2.712m ± 2%       ~ (p=0.301 n=20)
LintRule/L010        793.7µ ± 12%   698.0µ ± 0%       ~ (p=0.038 n=20)
geomean              5.462m         5.366m       -1.76%

                  │     base     │                head                 │
                  │     B/s      │     B/s       vs base               │
LintRW/postgresql   5.608Mi ± 1%   5.641Mi ± 1%       ~ (p=0.049 n=20)
LintRW/mysql        6.037Mi ± 1%   6.022Mi ± 1%       ~ (p=0.846 n=20)
LintRW/mariadb      6.175Mi ± 2%   6.208Mi ± 2%       ~ (p=0.825 n=20)
LintRW/sqlserver    6.628Mi ± 1%   6.661Mi ± 1%       ~ (p=0.432 n=20)
LintRW/oracle       7.138Mi ± 1%   7.129Mi ± 2%       ~ (p=0.867 n=20)
LintRW/sqlite       6.328Mi ± 2%   6.413Mi ± 3%       ~ (p=0.279 n=20)
LintRW/snowflake    6.537Mi ± 3%   6.580Mi ± 3%       ~ (p=0.330 n=20)
LintRW/clickhouse   6.065Mi ± 4%   6.275Mi ± 3%       ~ (p=0.262 n=20)
geomean             6.300Mi        6.353Mi       +0.84%

                   │      base      │                 head                  │
                   │      B/op      │     B/op      vs base                 │
LintParallel/rules   5.559Mi ± 0%     5.559Mi ± 0%       ~ (p=0.673 n=20)
LintParallel/lint    17.95Mi ± 0%     17.95Mi ± 0%       ~ (p=0.888 n=20)
LintRW/postgresql    1.966Mi ± 0%     1.966Mi ± 0%       ~ (p=0.256 n=20)
LintRW/mysql         2.508Mi ± 0%     2.508Mi ± 0%       ~ (p=0.995 n=20)
LintRW/mariadb       2.280Mi ± 0%     2.280Mi ± 0%       ~ (p=0.846 n=20)
LintRW/sqlserver     1.971Mi ± 0%     1.971Mi ± 0%       ~ (p=0.794 n=20)
LintRW/oracle        2.435Mi ± 0%     2.435Mi ± 0%       ~ (p=0.516 n=20)
LintRW/sqlite        2.173Mi ± 0%     2.173Mi ± 0%       ~ (p=0.878 n=20)
LintRW/snowflake     2.172Mi ± 0%     2.172Mi ± 0%       ~ (p=0.176 n=20)
LintRW/clickhouse    2.440Mi ± 0%     2.440Mi ± 0%       ~ (p=0.394 n=20)
LintRule/L007        92.98Ki ± 0%     92.98Ki ± 0%       ~ (p=1.000 n=20) ¹
LintRule/L010          0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                           ²                 -0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                   │     base      │                 head                 │
                   │   allocs/op   │  allocs/op   vs base                 │
LintParallel/rules   68.93k ± 0%     68.93k ± 0%       ~ (p=0.765 n=20)
LintParallel/lint    126.7k ± 0%     126.7k ± 0%       ~ (p=0.544 n=20)
LintRW/postgresql    14.13k ± 0%     14.13k ± 0%       ~ (p=1.000 n=20)
LintRW/mysql         17.46k ± 0%     17.46k ± 0%       ~ (p=1.000 n=20)
LintRW/mariadb       15.76k ± 0%     15.76k ± 0%       ~ (p=0.514 n=20)
LintRW/sqlserver     13.87k ± 0%     13.87k ± 0%       ~ (p=0.487 n=20)
LintRW/oracle        16.86k ± 0%     16.86k ± 0%       ~ (p=1.000 n=20) ¹
LintRW/sqlite        15.74k ± 0%     15.74k ± 0%       ~ (p=0.487 n=20)
LintRW/snowflake     15.20k ± 0%     15.20k ± 0%       ~ (p=1.000 n=20)
LintRW/clickhouse    17.66k ± 0%     17.66k ± 0%       ~ (p=0.231 n=20)
LintRule/L007        1.194k ± 0%     1.194k ± 0%       ~ (p=1.000 n=20) ¹
LintRule/L010         0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                          ²                +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                  │     base     │                head                │
                  │   sec/stmt   │  sec/stmt    vs base               │
LintRW/postgresql   16.55µ ±  1%   16.47µ ± 1%       ~ (p=0.040 n=20)
LintRW/mysql        13.09µ ±  1%   13.11µ ± 1%       ~ (p=0.836 n=20)
LintRW/mariadb      13.00µ ±  2%   12.93µ ± 2%       ~ (p=0.820 n=20)
LintRW/sqlserver    16.87µ ±  1%   16.78µ ± 1%       ~ (p=0.387 n=20)
LintRW/oracle       15.12µ ±  1%   15.15µ ± 2%       ~ (p=0.888 n=20)
LintRW/sqlite       13.04µ ±  2%   12.86µ ± 3%       ~ (p=0.280 n=20)
LintRW/snowflake    14.59µ ±  3%   14.49µ ± 3%       ~ (p=0.372 n=20)
LintRW/clickhouse   13.58µ ±  4%   13.13µ ± 3%       ~ (p=0.277 n=20)
LintRule/L007       978.8n ±  2%   964.0n ± 2%       ~ (p=0.301 n=20)
LintRule/L010       282.1n ± 12%   248.2n ± 1%       ~ (p=0.042 n=20)
geomean             7.430µ         7.275µ       -2.08%

pkg: github.com/ajitpratap0/GoSQLX/pkg/sql/keywords
                         │     base     │                head                 │
                         │    sec/op    │    sec/op     vs base               │
DetectDialect/empty        2.499n ± 13%   2.657n ± 17%       ~ (p=0.703 n=20)
DetectDialect/generic      304.1n ±  0%   305.2n ±  1%       ~ (p=0.140 n=20)
DetectDialect/postgresql   390.6n ±  0%   390.4n ±  0%       ~ (p=0.825 n=20)
DetectDialect/mysql        342.7n ±  1%   347.3n ±  1%       ~ (p=0.059 n=20)
DetectDialect/sqlserver    383.6n ±  1%   383.6n ±  1%       ~ (p=0.841 n=20)
DetectDialect/oracle       355.2n ±  0%   355.7n ±  1%       ~ (p=0.372 n=20)
DetectDialect/snowflake    519.3n ±  1%   520.6n ±  0%       ~ (p=0.588 n=20)
DetectDialect/mariadb      280.6n ±  0%   282.6n ±  1%       ~ (p=0.052 n=20)
DetectDialect/mixed        443.0n ±  1%   443.6n ±  1%       ~ (p=0.683 n=20)
DetectDialect/large_64KB   469.8µ ±  1%   471.6µ ±  1%       ~ (p=0.024 n=20)
geomean                    459.6n         463.9n        +0.94%

                         │     base     │                head                 │
                         │     B/s      │     B/s       vs base               │
DetectDialect/generic      166.2Mi ± 0%   165.6Mi ± 1%       ~ (p=0.129 n=20)
DetectDialect/postgresql   163.6Mi ± 0%   163.7Mi ± 0%       ~ (p=0.836 n=20)
DetectDialect/mysql        161.4Mi ± 1%   159.3Mi ± 1%       ~ (p=0.060 n=20)
DetectDialect/sqlserver    161.6Mi ± 1%   161.6Mi ± 1%       ~ (p=0.841 n=20)
DetectDialect/oracle       163.8Mi ± 0%   163.6Mi ± 1%       ~ (p=0.398 n=20)
DetectDialect/snowflake    163.4Mi ± 1%   163.0Mi ± 0%       ~ (p=0.597 n=20)
DetectDialect/mariadb      159.8Mi ± 0%   158.6Mi ± 1%       ~ (p=0.052 n=20)
DetectDialect/mixed        159.3Mi ± 1%   159.1Mi ± 1%       ~ (p=0.684 n=20)
DetectDialect/large_64KB   133.2Mi ± 1%   132.7Mi ± 1%       ~ (p=0.022 n=20)
geomean                    158.8Mi        158.3Mi       -0.36%

                         │     base     │                head                 │
                         │     B/op     │    B/op     vs base                 │
DetectDialect/empty        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/generic      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/postgresql   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/mysql        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/sqlserver    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/oracle       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/snowflake    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/mariadb      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/mixed        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/large_64KB   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                               ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                         │     base     │                head                 │
                         │  allocs/op   │ allocs/op   vs base                 │
DetectDialect/empty        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/generic      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/postgresql   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/mysql        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/sqlserver    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/oracle       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/snowflake    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/mariadb      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/mixed        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
DetectDialect/large_64KB   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                               ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/ajitpratap0/GoSQLX/pkg/sql/tokenizer
                         │    base     │                head                │
                         │   sec/op    │   sec/op     vs base               │
Tokenize/scratch/join      1.485µ ± 1%   1.492µ ± 2%       ~ (p=0.693 n=20)
Tokenize/scratch/complex   3.937µ ± 1%   3.979µ ± 3%       ~ (p=0.185 n=20)
Tokenize/scratch/insert    752.7n ± 2%   754.0n ± 3%       ~ (p=0.723 n=20)
geomean                    1.639µ        1.648µ       +0.57%

                         │     base     │                head                 │
                         │     B/s      │     B/s       vs base               │
Tokenize/scratch/join      80.94Mi ± 1%   80.56Mi ± 2%       ~ (p=0.703 n=20)
Tokenize/scratch/complex   91.56Mi ± 1%   90.60Mi ± 3%       ~ (p=0.189 n=20)
Tokenize/scratch/insert    96.29Mi ± 2%   96.13Mi ± 3%       ~ (p=0.713 n=20)
geomean                    89.36Mi        88.86Mi       -0.56%

                         │     base     │                head                 │
                         │     B/op     │    B/op     vs base                 │
Tokenize/scratch/join      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
Tokenize/scratch/complex   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
Tokenize/scratch/insert    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                               ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                         │     base     │                head                 │
                         │  allocs/op   │ allocs/op   vs base                 │
Tokenize/scratch/join      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
Tokenize/scratch/complex   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
Tokenize/scratch/insert    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20) ¹
geomean                               ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/ajitpratap0/GoSQLX/pkg/transform
                             │    base     │                head                │
                             │   sec/op    │   sec/op     vs base               │
TransformParse/simple_select   1.563µ ± 1%   1.571µ ± 1%       ~ (p=0.490 n=20)
TransformParse/join            5.016µ ± 1%   4.966µ ± 1%       ~ (p=0.229 n=20)
TransformParse/complex         13.11µ ± 1%   13.02µ ± 2%       ~ (p=0.644 n=20)
geomean                        4.684µ        4.665µ       -0.39%

                             │     base     │                 head                  │
                             │     B/op     │     B/op      vs base                 │
TransformParse/simple_select     704.0 ± 0%     704.0 ± 0%       ~ (p=1.000 n=20) ¹
TransformParse/join            1.789Ki ± 0%   1.789Ki ± 0%       ~ (p=1.000 n=20) ¹
TransformParse/complex         4.883Ki ± 0%   4.883Ki ± 0%       ~ (p=1.000 n=20) ¹
geomean                        1.818Ki        1.818Ki       +0.00%
¹ all samples are equal

                             │    base    │                head                 │
                             │ allocs/op  │ allocs/op   vs base                 │
TransformParse/simple_select   3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=20) ¹
TransformParse/join            15.00 ± 0%   15.00 ± 0%       ~ (p=1.000 n=20) ¹
TransformParse/complex         43.00 ± 0%   43.00 ± 0%       ~ (p=1.000 n=20) ¹
geomean                        12.46        12.46       +0.00%
¹ all samples are equal

pkg: github.com/ajitpratap0/GoSQLX/wasm/internal/bridge
                        │    base     │                head                │
                        │   sec/op    │   sec/op     vs base               │
WASMBridge/parse/small    4.804µ ± 1%   4.834µ ± 1%       ~ (p=0.163 n=20)
WASMBridge/parse/medium   21.19µ ± 1%   21.21µ ± 1%       ~ (p=0.659 n=20)
WASMBridge/parse/large    194.5µ ± 1%   195.4µ ± 1%       ~ (p=0.277 n=20)
WASMBridge/lint/small     6.727µ ± 1%   6.694µ ± 1%       ~ (p=0.365 n=20)
WASMBridge/lint/medium    30.98µ ± 1%   31.36µ ± 1%       ~ (p=0.114 n=20)
WASMBridge/lint/large     159.0µ ± 1%   161.6µ ± 1%       ~ (p=0.149 n=20)
geomean                   29.48µ        29.65µ       +0.60%

                        │     base     │                head                 │
                        │     B/s      │     B/s       vs base               │
WASMBridge/parse/small    7.744Mi ± 1%   7.696Mi ± 1%       ~ (p=0.159 n=20)
WASMBridge/parse/medium   11.74Mi ± 1%   11.73Mi ± 1%       ~ (p=0.654 n=20)
WASMBridge/parse/large    5.755Mi ± 1%   5.732Mi ± 0%       ~ (p=0.291 n=20)
WASMBridge/lint/small     5.527Mi ± 1%   5.555Mi ± 1%       ~ (p=0.343 n=20)
WASMBridge/lint/medium    8.035Mi ± 1%   7.935Mi ± 1%       ~ (p=0.119 n=20)
WASMBridge/lint/large     7.043Mi ± 1%   6.928Mi ± 1%       ~ (p=0.155 n=20)
geomean                   7.396Mi        7.353Mi       -0.58%

                        │     base     │                 head                  │
                        │     B/op     │     B/op      vs base                 │
WASMBridge/parse/small    1.531Ki ± 0%   1.531Ki ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/parse/medium   5.961Ki ± 0%   5.961Ki ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/parse/large    74.97Ki ± 0%   74.97Ki ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/small     4.492Ki ± 0%   4.492Ki ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/medium    16.02Ki ± 0%   16.02Ki ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/large     123.5Ki ± 0%   123.5Ki ± 0%       ~ (p=1.000 n=20)
geomean                   13.51Ki        13.51Ki       -0.00%
¹ all samples are equal

                        │    base     │                 head                 │
                        │  allocs/op  │  allocs/op   vs base                 │
WASMBridge/parse/small     8.000 ± 0%    8.000 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/parse/medium    38.00 ± 0%    38.00 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/parse/large     522.0 ± 0%    522.0 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/small      33.00 ± 0%    33.00 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/medium     100.0 ± 0%    100.0 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/large     1.031k ± 0%   1.031k ± 0%       ~ (p=1.000 n=20) ¹
geomean                    90.24         90.24       +0.00%
¹ all samples are equal

                        │    base     │                 head                 │
                        │   outB/op   │   outB/op    vs base                 │
WASMBridge/parse/small     635.0 ± 0%    635.0 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/parse/medium   2.661k ± 0%   2.661k ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/parse/large    33.16k ± 0%   33.16k ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/small      22.00 ± 0%    22.00 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/medium     293.0 ± 0%    293.0 ± 0%       ~ (p=1.000 n=20) ¹
WASMBridge/lint/large      294.0 ± 0%    294.0 ± 0%       ~ (p=1.000 n=20) ¹
geomean                    688.2         688.2       +0.00%
¹ all samples are equal

Run, raw data and benchstat

Test and others added 2 commits November 7, 2026 07:36
…sh [W2-07]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 16s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good. I found no blocking issues.

I read the production diff and lookup_fold.go in full. I did not run the tests or benchmarks. I rely on your description and the perf gate comment for those numbers.

Correctness

  • lookupFold matches strings.ToUpper on every input class:
    • Pure-ASCII words of 64 bytes or fewer are upper-cased into a stack buffer.
    • Any byte at or above utf8.RuneSelf breaks out of the loop and falls back to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
    • Words over 64 bytes take the same fallback.
  • m[string(buf[:len(s)])] is the map-index form the compiler does not allocate for. Your escape-analysis note confirms it.
  • The case-sensitive paths are unchanged.
  • GetKeyword still upper-cases unconditionally, as before, so its behaviour is preserved.
  • On a miss, GetKeywordType and GetTokenType return TokenTypeWord, which is equivalent to the old behaviour.

Performance

  • The perf gate passes. Allocs/op, B/op and instructions/op are unchanged on all gated benchmarks. The suite geomean is +0.15% (p=0.355), within the A/A' control's noise.
  • This is expected, since the consumers' corpora are already upper case. The gain shows on BenchmarkKeywordLookup.
  • The 64-byte buffer is zero-initialised on every call. For short keywords that cost is small next to an allocation.
  • The IsKeyword/long +4.75% result is almost certainly noise, since the len > 64 path is unchanged.

Tests

  • The differential oracle, fuzz target, "built-in keys fit" pin, zero-alloc test and the M1–M7 mutation checks are the right set.
  • Minor suggestion: confirm the oracle covers lengths of exactly 63, 64 and 65 bytes, since that is where a <= boundary regression would show. The commit message says the ASCII-boundary mutants were killed, so this may already be covered.

Nits

  • The keyBufLen comment says "longest is 20 bytes on origin/main". That will go stale as keywords are added, and the pinning test already enforces the invariant. Consider dropping the number.
  • The IsKeyword doc line "Pure-ASCII words up to 64 bytes…" sits directly under the summary line without a // separator. That is cosmetic. GetKeywordType already separates it correctly.
  • The "64 bytes" literal is repeated in several doc comments. A reference to keyBufLen would keep them in sync, but it's not important.

No security concerns. This is pure lookup logic with no unsafe code and no new inputs.
· branch perf/w2-07-alloc-free-keywords-api

#961 replaced direct CHANGELOG.md edits with per-PR changelog.d/
fragments. This also restores CHANGELOG.md to its merge-base content,
dropping any leftover conflict markers. The entry text is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 15s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good. I found no blocking issues.

I read pkg/sql/keywords/lookup_fold.go in full. I also grepped the tests for boundary cases. git diff origin/main...HEAD failed here with "no merge base", so I did not read the consumer-file diffs line by line. I did not run the tests or benchmarks. The numbers below come from the PR description and the perf gate comment.

Correctness

  • lookupFold matches strings.ToUpper for every input class:
    • A pure-ASCII word of 64 bytes or fewer is upper-cased into a stack buffer.
    • Any byte at or above utf8.RuneSelf breaks out of the loop and falls back to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
    • Words over 64 bytes also fall back.
    • The i == len(s) check handles the empty string.
  • m[string(buf[:len(s)])] is the map-index form the compiler does not allocate for. Your escape-analysis note confirms this.

Performance

  • The perf gate passes. Allocs/op and B/op are unchanged on every gated benchmark, and the suite geomean is within the A/A' noise. That is expected, because no gated benchmark exercises keyword lookups. The real gain is BenchmarkKeywordLookup (allocs 1 → 0), pinned by TestLookupFold_NoAllocs.
  • var buf [64]byte is zeroed on every call. For short keywords that costs far less than an allocation.
  • The IsKeyword/long +4.75% result is almost certainly noise. The len > 64 path is unchanged apart from one extra length compare.

Tests

  • The test set is the right one: differential oracle, fuzz target, a check that built-in keys fit the fast path, and the zero-alloc test.
  • The boundary cases I asked about earlier are covered. lookup_fold_test.go has 63/64/65/200-byte inputs and the A@B / A[B keys.

Nits (non-blocking)

  • The keyBufLen comment says "longest is 20 bytes on origin/main". That number will go stale as keywords are added, and the pinning test already enforces the invariant. Consider dropping it.
  • Several doc comments repeat the "64 bytes" literal. Referring to keyBufLen would keep them in sync.

No security concerns. This is pure lookup logic with no unsafe code and no new inputs.
· branch perf/w2-07-alloc-free-keywords-api

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 16s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good. I found no blocking issues.

I read pkg/sql/keywords/lookup_fold.go in full. I did not run the tests or benchmarks. The numbers below come from the PR description and the earlier perf-gate comment.

Correctness

  • lookupFold matches strings.ToUpper for every input class.
    • A pure-ASCII word of 64 bytes or fewer is upper-cased into a stack buffer.
    • A byte at or above utf8.RuneSelf breaks out of the loop and falls back to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
    • Words over 64 bytes also fall back.
    • The i == len(s) check handles the empty string.
  • m[string(buf[:len(s)])] is the map-index form the compiler does not allocate for.

Performance

  • The perf gate passes: allocs/op and B/op are unchanged on every gated benchmark. That is expected, because no gated benchmark exercises keyword lookups. The real gain is BenchmarkKeywordLookup (allocs 1 → 0), pinned by TestLookupFold_NoAllocs.
  • var buf [64]byte is zeroed on every call. For short keywords that costs far less than an allocation.

Tests

  • The test set fits the change: differential oracle, fuzz target, a check that built-in keys fit the fast path, the zero-alloc test and the mutation checks.
  • Earlier reviews found 63/64/65/200-byte boundary inputs and the A@B / A[B keys in lookup_fold_test.go. I did not re-check them this time.

Nits (non-blocking)

  • The keyBufLen doc comment (lines 22–24) wraps awkwardly, with a short line after "a test pins". Re-flowing it is cosmetic.
  • Several doc comments repeat the "64 bytes" literal. Referring to keyBufLen would keep them in sync.

No security concerns. This is pure lookup logic with no unsafe code and no new inputs.
· branch perf/w2-07-alloc-free-keywords-api

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 15s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good. I found no blocking issues.

I read pkg/sql/keywords/lookup_fold.go in full. I did not run the tests or benchmarks, and I did not re-read the consumer diffs. The numbers come from the PR description and the perf gate comment.

Correctness

  • lookupFold should match m[strings.ToUpper(s)] for every input class:
    • A pure-ASCII word of 64 bytes or fewer is upper-cased into a stack buffer.
    • A byte at or above utf8.RuneSelf breaks out of the loop and falls back to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
    • Words over 64 bytes also fall back.
    • The i == len(s) check handles the empty string.
  • m[string(buf[:len(s)])] is the map-index form the compiler does not allocate for. Your escape-analysis note confirms it.

Performance

  • The perf gate passes, with allocs/op and B/op unchanged on every gated benchmark. That is expected, because no gated benchmark exercises keyword lookups. The real gain is BenchmarkKeywordLookup (allocs 1 → 0), pinned by TestLookupFold_NoAllocs.
  • var buf [64]byte is zeroed on every call. For short keywords that costs far less than an allocation.

Tests

  • The test set fits the change: differential oracle, fuzz target, a check that built-in keys fit the fast path, the zero-alloc test and the mutation checks.
  • Earlier reviews found 63/64/65/200-byte boundary inputs and the A@B / A[B keys in the tests. I did not re-check them this time.

Nits (non-blocking)

  • Several doc comments repeat the "64 bytes" literal. Referring to keyBufLen would keep them in sync.

No security concerns. This is pure lookup logic with no unsafe code and no new inputs.
· branch perf/w2-07-alloc-free-keywords-api

…[W2-07]

The amd64 matrix run 43702780432 (EPYC 9V74, base ed66d3b, head c7ddd49)
showed upper-case input 47-78% slower than the old strings.ToUpper path:
ToUpper returns s unchanged when there is nothing to fold, while lookupFold
always zeroed and filled a 64-byte stack buffer. lookupFold now scans first
and indexes the map with s itself when s is already upper-case ASCII, and
copies only the scanned prefix into the buffer otherwise.

Local M4 benchstat vs the old code (n=6): upper -12% to -27% (was -2% to
-19%), lower/mixed/miss -60% to -72%, long unchanged, allocs 1 -> 0 kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 13s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good. I found no blocking issues.

I read pkg/sql/keywords/lookup_fold.go in full. I did not run the tests or benchmarks, and I did not re-read the consumer diffs. The numbers come from the PR description and the earlier perf-gate comment.

Correctness

  • lookupFold should match m[strings.ToUpper(s)] for every input class.
    • The first loop finds input that is already upper-case ASCII, including the empty string. It indexes m[s] directly with no copy, the same result strings.ToUpper gives when it returns s unchanged.
    • Input of 64 bytes or fewer that is pure ASCII is upper-cased into a stack buffer. The prefix already scanned is copied, and the loop resumes from index i.
    • A byte at or above utf8.RuneSelf breaks out and falls back to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
    • Words over 64 bytes take the same fallback.
  • m[string(buf[:len(s)])] is the map-index form the compiler does not allocate for. The PR's escape-analysis note confirms it.

Performance

  • Already-upper-case input now skips the buffer entirely, which is the common spelling in the consumers.
  • var buf [64]byte is zeroed only on the mixed-case path. That costs far less than an allocation.
  • The perf gate is flat, as expected. No gated benchmark exercises keyword lookups. The real gain is BenchmarkKeywordLookup (allocs 1 → 0), pinned by TestLookupFold_NoAllocs.

Tests

  • The test set fits the change: differential oracle, fuzz target, a check that built-in keys fit the fast path, the zero-alloc test and the mutation checks.
  • Earlier reviews found 63/64/65/200-byte boundary inputs and the A@B / A[B keys in the tests. I did not re-check them this time.

Nits (non-blocking)

  • Several doc comments repeat the "64 bytes" literal. Referring to keyBufLen would keep them in sync.

No security concerns. This is pure lookup logic with no unsafe code and no new inputs.
· branch perf/w2-07-alloc-free-keywords-api

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 14s —— View job


Review of PR #944: allocation-free keyword lookups

Verdict: looks good. I found no blocking issues.

I read pkg/sql/keywords/lookup_fold.go in full. I did not run the tests or benchmarks, and I did not re-read the consumer diffs. The numbers come from the PR description and the earlier perf-gate comment.

Correctness

  • lookupFold should match m[strings.ToUpper(s)] for every input class:
    • Already upper-case ASCII, including the empty string. The first loop reaches len(s) and indexes m[s] directly. strings.ToUpper also returns s unchanged here.
    • Mixed or lower-case ASCII of 64 bytes or fewer. The prefix scanned so far is copied. The rest is upper-cased into the stack buffer, and the map is indexed with string(buf[:len(s)]), which the compiler does not allocate.
    • A non-ASCII byte, or length over keyBufLen. These fall through to strings.ToUpper. That covers ſ→S, ı→I and invalid UTF-8.
  • The first loop also breaks on a non-ASCII byte. The copy then covers only the ASCII prefix, and the second loop breaks on the same byte, so no half-built buffer is ever used. This is correct.

Performance

  • Upper-case input skips the buffer entirely. The var buf zeroing is paid only on the mixed-case path.
  • The perf gate is flat, as expected, because no gated benchmark exercises keyword lookups. The gain is BenchmarkKeywordLookup (allocs 1 → 0), pinned by TestLookupFold_NoAllocs.
  • The long-input (65-byte) case is +17% to +25% on amd64 in your report-only run. That path now does one extra scan before strings.ToUpper. It is disclosed in the PR and is irrelevant for real keywords. If you want to close it, a length check ahead of the first scan would skip the extra pass for inputs over keyBufLen. That would only be correct if you still want the "already upper-case, long" case to avoid allocating.

Tests

  • The differential oracle, fuzz target, the "built-in keys fit" pin, the zero-alloc test and the mutation checks fit the change.
  • Earlier reviews found the 63/64/65/200-byte boundary inputs and the A@B / A[B keys in the tests. I did not re-check them this time.

Nits (non-blocking)

  • Several doc comments repeat the "64 bytes" literal. Referring to keyBufLen would keep them in sync.

No security concerns. This is pure lookup logic with no unsafe code and no new inputs.
· branch perf/w2-07-alloc-free-keywords-api

@ajitpratap0
ajitpratap0 merged commit e25fa96 into main Nov 15, 2026
52 checks passed

This branch was successfully deployed

1 active deployment
Preview — 5a695728 Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dialects documentation Improvements or additions to documentation performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant