Repository navigation
perf(cbinding): pool JSON scratch, release ASTs and cache linters [W8-01] - #943
ajitpratap0 wants to merge 4 commits into
Conversation
…-01] 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. 1 Skipped Deployment
|
|
Claude finished @ajitpratap0's task in 21s —— View job Review of PR #943: cbinding overheadI read the main changes ( What looks correct
Minor suggestions (non-blocking)
Test coverage: thorough. It includes corpus byte-equality, edge inputs (invalid UTF-8, U+2028/9, Overall this looks good to merge once CI is green. |
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.841. Low power6 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) |
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 #943: cbinding overheadI read Correct
Non-blocking suggestions
Tests: thorough. They cover corpus byte equality, edge inputs, state-leak checks, cache bounds, concurrency, Overall this looks good to merge once CI is green. |
…nding [W8-01] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 17s —— View job Review of PR #943: cbinding overheadI read Correct
Non-blocking suggestions
Perf gate: the gate reports PASS on the gated suite. Allocs/op are unchanged there, as expected. Tests: thorough. They cover corpus byte equality, edge inputs, state-leak checks, cache bounds, concurrency, the This looks good to merge once CI is green. |
Summary
Removes per-call Go overhead from the C binding (CB-1 Go side). C ABI, JSON bytes and Go API are unchanged.
json.Encoderand copied once into C memory (C.CBytes); theEncodenewline is replaced by the NUL terminator.ast.ReleaseASTon the parse, extract and metadata paths.map[string]interface{}(same key order,errorbeforeerror_code).(max_line_length, dialect), capped at 64 entries (max_line_length is any positive int); stored linters are never mutated. Relies on the shared-linter invariant ofgosqlx.defaultLinter, W6-05a (fix(linter): make Context.Nodes safe for concurrent rule Check [W6-05a] #928) and D16 (rules must not retain AST/token references after Check).#566 objection ("some paths may retain node pointers"): checked per path. Parse results hold only string constants (statement type names); extract results hold string copies; metadata holds string copies built before release; nothing points into the AST after
ReleaseAST.Rejected (PLAN section 6): reading the caller's C string without copying (use-after-free risk) and a hand-written JSON encoder (would re-implement encoding/json escaping).
Test Plan
task check(clean on rerun; first run hit load-induced timeouts in unrelated packages, load average ~80 on the shared M4),task test:cbinding,go test -count=1 ./pkg/compatibility/...,staticcheck ./pkg/cbinding/: pass.<&>, unknown dialect, >200 KB), no state leak across success/error/zero-statement calls, cached-vs-fresh linter for all dialects x maxLen, cache bound (counter == entries <= 64), 16-goroutine concurrent equivalence under-race,keepScratchboundaries, and!raceAllocsPerRun guards (parse -5, lint -13 on medium). Six mutations (no newline trim, no zeroing, dialect-only key, no cap, no ReleaseAST on parse, metadata and extract paths) each fail a new test: the equivalence, cache and scratch mutations fail under-race(task test:cbinding); the alloc and ReleaseAST mutations fail under the non-race step now run bytask test:cbinding(go test -count=1 -timeout 60s -run 'TestCBindingAlloc' ./pkg/cbinding/, so CI and release.yml enforce them; extract guard renamed TestCBindingAllocExtractASTRelease to match) (metadata/extract release guards added in the fix round via no-release reference helpers). The nil-initial-stmtTypes mutation survives by design: a nil dst falls back to a non-nil allocation, so the zero-statement '[]' is preserved.test:cbindingtimeout (timeout not changed).ab.shforces CGO off, so cbinding was A/B'd with a hand-run interleaved ABBA, 10 rounds, GOGC=off GOMEMLIMIT=64MiB GOMAXPROCS=1, base = origin/main @ 6399dc0 with only the new bench file copied in;benchstat -alpha 0.01.allocs/op and B/op are deterministic (p=0.000, n=10 every row). Target (parse -4 allocs/op) met: -6 at all sizes; lint -14. ns/op: geomean -13.5% but every row is
~(load average 80-118 on the shared machine, CIs 50-500%), so ns/op is indicative only.Breaking Changes
None. C ABI, JSON bytes and Go API unchanged.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2