Repository navigation
perf(keywords): allocation-free case-insensitive keyword lookups [W2-07] - #944
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task in 20s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: 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
Performance
Tests
Nits
No security concerns. The change is pure lookup logic with no new inputs or unsafe code. |
Perf gate: PASS (shadow mode: report only, this check never fails)Base Runner CPU:
Rules: each arm runs 20 randomized code 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)
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 powerAdaptive 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.
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)
Secondary metric: default GC, GOMAXPROCS=1 (informational)
Environmentbenchstat (primary metric, samples pooled across layouts: informational, the verdict uses the per-layout test) |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
…sh [W2-07] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 16s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: looks good. I found no blocking issues. I read the production diff and Correctness
Performance
Tests
Nits
No security concerns. This is pure lookup logic with no unsafe code and no new inputs. |
#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
|
Claude finished @ajitpratap0's task in 15s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: looks good. I found no blocking issues. I read Correctness
Performance
Tests
Nits (non-blocking)
No security concerns. This is pure lookup logic with no |
…-keywords-api # Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
…g.d [W2-07] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 16s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: looks good. I found no blocking issues. I read Correctness
Performance
Tests
Nits (non-blocking)
No security concerns. This is pure lookup logic with no |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 15s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: looks good. I found no blocking issues. I read Correctness
Performance
Tests
Nits (non-blocking)
No security concerns. This is pure lookup logic with no |
…[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
|
Claude finished @ajitpratap0's task in 13s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: looks good. I found no blocking issues. I read Correctness
Performance
Tests
Nits (non-blocking)
No security concerns. This is pure lookup logic with no |
|
Claude finished @ajitpratap0's task in 14s —— View job Review of PR #944: allocation-free keyword lookupsVerdict: looks good. I found no blocking issues. I read Correctness
Performance
Tests
Nits (non-blocking)
No security concerns. This is pure lookup logic with no |
Summary
lookupFoldhelper (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 tostrings.ToUpper. Used byIsKeyword,GetKeywordType,IsReserved,GetKeyword,GetTokenType,IsCompoundKeywordStartandcontainsKeyword. Results are identical for every input (Unicode folds such asſelect, invalid UTF-8, long words, case-sensitive instances).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), becauselookupFoldalways zeroed and filled a 64-byte buffer whilestrings.ToUpperreturnssunchanged.lookupFoldnow scans first and indexes the map withsdirectly when it is already upper-case ASCII.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).Test Plan
task test:cbinding,go test ./pkg/compatibility/..., staticcheck on./pkg/sql/keywords/...: pass.go test -raceon keywords, formatter, highlight, mcp: pass.can inline lookupFold[...],string(buf[:len(s)]) does not escape.task bench:ab BASE=<commit1>(20 layouts, indicative, shared M4): lower/mixed/miss allocs 1 -> 0, B/op -> 0 for all six methods.go test -run TestLookupFold ./pkg/sql/keywords/): M8'a' <= c->'`' <= cand M9c <= 'z'->c <= '{'are killed by theAddKeyword("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.TestLookupFold_NoAllocs; withlookupFoldtemporarily replaced bym[strings.ToUpper(s)],go test -count=1 -run TestLookupFold_NoAllocs ./pkg/sql/keywords/reports 46 FAIL lines (restored afterwards).BenchmarkKeywordLookup, so it gave no A/B delta.BenchmarkKeywordLookuprows only, 5 layouts per arm (smallest p 0.008):strings.Repeat("x", 65),pkg/sql/keywords/lookup_bench_test.go:46, abovekeyBufLen, takes thestrings.ToUpperfallback): +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-bytestrings.ToUpperresult rounded to the 80-byte size class.Nodes()trade-off). Only theBenchmarkKeywordLookuprows isolate this change.task check,task test:cbinding, compatibility and staticcheck passed on 3dcfe7d; f681c44 changes onlylookupFoldand passesgo 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
5a695728e596merged 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.