Repository navigation
perf(tokenizer): single fused-hash keyword table [W2-01] - #920
Conversation
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 28s —— View job Review of PR #920: fused-hash keyword tableVerdict: looks correct and low-risk. I have a few minor suggestions and no blockers. I read the diff and grepped for related uses. I did not run the tests or benchmarks.
Correctness
Suggestions (non-blocking)
Benchmarks and performanceThe PR notes the local numbers are indicative only (p=0.28 for tokenize and p=0.63 for E2E). The Tests
SecurityNo concerns. There is no external input to the table, and the buffer sizes are bounded by OtherThe CHANGELOG entry is present. |
Perf gate: PASS (shadow mode: report only, this check never fails)Base
Rules: time regresses at >= +3% with p < 0.01 (Mann-Whitney U), or a suite geomean >= +1.5% (per-round 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%. An A/A control with more than 10% of benchmarks moving over 3% is noisy: re-run once, then inconclusive (neutral). Gated suite (GOGC=off, GOMAXPROCS=1)
A/A control: 0 of 26 benchmarks moved more than 3%. Instructions per operation (cmd/perfdriver)
Secondary metric: default GC, GOMAXPROCS=1 (informational)
Environmentbenchstat (primary metric) |
… slot [W2-01] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 22s —— View job Review of PR #920: fused-hash keyword tableVerdict: correct and low-risk. I found no blockers. I read the diff of Correctness
Suggestions (non-blocking)
PerformanceThe perf-gate (shadow) passes. The suite geomean is -6.72%, Tests
SecurityNo concerns. The table is built from static data, and the stack buffers are bounded by The CHANGELOG entry is present. |
|
Claude finished @ajitpratap0's task in 26s —— View job Review of PR #920: fused-hash keyword tableVerdict: correct and low-risk, no blockers. I read the diff for An earlier review on this PR suggested a Correctness
Suggestions (non-blocking)
Tests
SecurityNo concerns. The table is built only from internal constants, and the key buffer is bounded by PerformanceThe CI numbers meet the plan thresholds (ParseE2E -4% to -7.5%, Tokenize/scratch -13% to -22%, instructions/op down 4.7% to 8.8%). The local |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 19s —— View job Review of PR #920: fused-hash keyword tableVerdict: correct and low-risk, with no blockers. I read the full diff of Correctness
Suggestions (non-blocking)
PerformanceThe CI perf-gate (shadow mode) passes, with a suite geomean of -6.90% at p<0.001. Tests
SecurityNo concerns. The table is built only from static data, and the stack buffers are bounded by The CHANGELOG entry is present. |
Summary
PLAN W2-01 (TOK-1). Replaces the two Go map lookups per identifier (
keywordTokenTypes,compoundKeywordStarts) with one 512-slot open-addressed table generated at init from both maps. FNV-1a hashing is fused into the ASCII upper-casing loop, so a word costs one hash pass plus typically one probe. Non-ASCII words keep the existingstrings.ToUpper+ map path.IsKeywordalso uses the table. Ported fromverify-tokenizer/TOK-1.patchinto the existingkeyword_lookup.go.The parser-remap slot reserved by the plan is NOT a struct field yet: golangci-lint (
unused) rejects an unread field. W3-03 adds it tokwEntry(noted in a comment).No exported API change; token output unchanged (token goldens pass untouched, no golden diffs).
Test Plan
TestKwTableMatchesMaps: every key in both maps resolves identically (type, isKeyword, compoundStart) in upper/lower/mixed case; non-keywords miss; no duplicate keys; load factor < 0.5.TestIsKeywordMatchesMap: table-backedIsKeywordvs the map incl. non-ASCII and over-long words.task check: pass.task test:cbinding: pass.go test -count=1 ./pkg/compatibility/...: pass.staticcheck ./pkg/sql/tokenizer/: clean.task bench:ab BASE=origin/mainre-run on the final head (M4, shared machine,-r 10 -t 200ms, INDICATIVE ONLY; CI is authoritative):Tokenize/scratchsec/op geomean -16.1% (all 11 queries p=0.000),ParseE2Esec/op geomean -8.2% (all 11 p<=0.001); allocs/op and B/op unchanged. Local gate verdict geomean -12.24%. Full benchstat in the details block below.TestKeywordTableHotKeysAtHomeasserts the hot keys sit in their home slot.Tokenizer.keywordAtnow goes throughIsKeyword(single source of truth).ParseE2E-4.0% to -7.5% on all 11 queries (geomean -5.3%, computed from the gate's per-query rows; plan threshold -4%: met).Tokenize/scratchjoin -21.7%, complex -20.4%, insert -13.2% (geomean -18.5% computed from the 3 gated rows; plan threshold <= -11%: met).ParseRW/*/medium-5.5% to -6.7%. allocs/op and B/op unchanged, instructions/op -4.7% to -8.8%, no regression. The gate re-runs on the latest head (deterministic layout); see the sticky perf-gate comment on this PR for the current table.Local benchstat (sec/op), base origin/main vs head
Breaking Changes
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2