Repository navigation
perf(tokenizer): inline current-line window for token locations [W2-02] - #924
Conversation
…ions [W2-02] Cache the current line's start offsets so the per-token Start and End locations are a range check and a subtraction instead of two calls to toSQLPosition. Out-of-window offsets use the existing lookup, which reloads the window. Reset clears it. Positions are unchanged; an oracle test covers LF/CRLF/tabs/multibyte/BOM and pooled reuse. 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 25s —— View job Review of PR #924: inline current-line window for token locationsVerdict: looks correct and low-risk. I have only minor suggestions. I read the diff and compared it with Correctness
Suggestions (non-blocking)
Performance, security, race safety
|
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 32 benchmarks moved more than 3%. Instructions per operation (cmd/perfdriver)
Secondary metric: default GC, GOMAXPROCS=1 (informational)
Environmentbenchstat (primary metric) |
|
Claude finished @ajitpratap0's task in 19s —— View job Review of PR #924: inline current-line window for token locationsVerdict: correct and low-risk. I read the diff of Correctness
Suggestions (non-blocking)
Security and racesThe new fields are plain ints on a per-instance tokenizer, and |
Summary
Plan W2-02 (TOK-2).
tokenizenow caches the current line's[curLS, nextLS)window and line index, so each token's Start and End location is a range check plus a subtraction instead of two calls to the non-inlinabletoSQLPosition. Out-of-window offsets go tolocSlow, which uses the existing lookup and reloads the window.Resetclears the window. The window relies onlineStartsbeing immutable during tokenize; prescan and the BOM adjustment both finish before the first lookup. Ported from the verified prototypeverify-tokenizer/TOK-2.patch. No API change, and token positions are identical.Test Plan
pkg/sql/tokenizer/line_window_test.go:task check,task test:cbinding,go test -count=1 ./pkg/compatibility/...and staticcheck on./pkg/sql/tokenizer/: all pass. The behaviour goldens are unchanged.task bench:ab BASE=origin/main BENCH='./pkg/sql/tokenizer=^BenchmarkTokenize$' ROUNDS=10):Tokenize/scratch(the target): join -6.37%, complex -7.05%, insert -4.79%, all p<0.001. Their geomean is about -6.1%, slightly short of the PLAN threshold of <= -7%; reported, not chased.locFasthelper (the slow-path call would likely defeat inlining; the duplicated block is deliberate) and a white-box fast-path counter test.Breaking Changes
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2