Repository navigation
perf(ast): O(1) ReleaseAST for parser-built trees with no pooled draws [W4-01] - #930
Conversation
…s [W4-01] The parser counts nodes drawn from the AST pools and reports the count to ast.ReleaseAST through an internal hook; a zero count skips the release walk. Hand-built trees and trees with pooled draws keep the full walk. 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 39s —— View job Review of PR #930: O(1)
|
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: 1 of 32 benchmarks moved more than 3%. Instructions per operation (cmd/perfdriver)
Secondary metric: default GC, GOMAXPROCS=1 (informational)
Environmentbenchstat (primary metric) |
…t-path docs [W4-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 27s —— View job Review of PR #930: O(1)
|
…all-slices Brings in #926 (tokens built in place) and #930 (O(1) ReleaseAST). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
Summary
W4-01 (PLAN D3 option b). The parser counts nodes it draws from the AST pools and reports the count to
ast.ReleaseASTthrough an internal hook (pkg/sql/internal/astrelease, importable only underpkg/sql). A parser-built tree with zero pooled draws is released in O(1): onlyStatementsreferences are cleared and the container is pooled. Trees with pooled draws (tuples, arrays, subscripts/slices, ALTER/SHOW/DESCRIBE/REPLACE, sequences) and all hand-built trees keep the full walk. No exported API change; one unexportedAST.noPooledDrawsfield.Notes:
pkg/sql/parsercallp.notePooledDraw(). The heap-built&ast.TupleExpression{}inparseAssignmentTarget(UPDATE SET (a,b)=...) is counted too, so it is still recycled exactly as before.TestReleaseDrawnPolicy_ParserCountsDrawsfails if a parser function draws a pooled node without counting it;releaseDrawnConstructorsguard unchanged.(a,b) IN (...), UPDATE tuple assignment and PostgreSQL arrays keep the walk. Over the corpus x 5 dialects 10874 of 11774 parses are draw-free.Test Plan
TestPooledDraws_CountMatchesTree(all 11 pooled types covered),TestPooledDraws_CorpusEquivalence(differential: no pooled node in any zero-draw tree, 11774 parses),TestPooledDraws_ResetPerParse, ast fast-path/hand-built/flag-reset tests.task checkpass,task test:cbindingpass,go test -count=1 ./pkg/compatibility/...pass, staticcheck on pkg/sql/ast, parser, internal clean. Behaviour goldens unchanged.task bench:ab BASE=origin/main BENCH='./pkg/gosqlx=^BenchmarkParseE2E$' ROUNDS=8(M4, shared, indicative): geomean -3.74% (p<0.001); simple -3.2, where -4.4, join -4.3, aggregate -6.4, subquery -3.4, cte -4.4, window -1.5, complex -4.3, insert -0.6, update -3.4, delete -5.2. B/op and allocs/op unchanged.BenchmarkParseStage/release<= -70% (interleaved fixed-iteration A/B on the M4, 6 rounds,-benchtime 200000x -cpu 1, base = origin/main afec16a; fixed Nx becausetask bench:abnever finishes on this benchmark under GOGC=off: the StopTimer batch calibration grows b.N into the millions): geomean -83.9% (p=0.002), B/op flat. Per query: select_where -83.7%, join -89.0%, aggregate -88.6%, subquery -88.4%, cte -89.1%, window -81.3%, complex -95.9%, update -74.9%, delete -71.4%. Two queries MISS the -70% bar: simple_select -66.1% and insert -61.1%. Reported, not hidden; the geomean clears the target.TestPooledDraws_ParseMarksTree: real parses throughParseFromModelTokensandParseContextFromModelTokensmust mark the tree (noPooledDrawstrue for draw-free, false for a tuple, counter resets across parses). Removing theMarkParserBuiltcall fails it.Perf gate: PASS (shadow mode: report only, this check never fails)
Base
afec16a41252, headd8977d30714d. 10 interleaved rounds, benchtime 200ms, -cpu 1, pinned to CPU 3 (SMT siblings 2-3) with taskset.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)
ParseE2E/simple_selectParseE2E/select_whereParseE2E/joinParseE2E/aggregateParseE2E/subqueryParseE2E/cteParseE2E/windowParseE2E/complexParseE2E/insertParseE2E/updateParseE2E/deleteParseRW/postgresql/mediumParseRW/mysql/mediumParseRW/mariadb/mediumParseRW/sqlserver/mediumParseRW/oracle/mediumParseRW/sqlite/mediumParseRW/snowflake/mediumParseRW/clickhouse/mediumParseFresh/simple_selectParseFresh/joinParseFresh/complexPoolGetPut/serialTokenize/scratch/joinTokenize/scratch/complexTokenize/scratch/insertNormalize/simple_selectNormalize/joinNormalize/complexTransformParse/simple_selectTransformParse/joinTransformParse/complexA/A control: 0 of 32 benchmarks moved more than 3%.
Instructions per operation (cmd/perfdriver)
e2e/aggregatee2e/complexe2e/ctee2e/deletee2e/inserte2e/joine2e/select_wheree2e/simple_selecte2e/subquerye2e/updatee2e/windowrw/postgresql/mediumBreaking Changes
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2