Repository navigation
perf(transpiler): cached reflection plans and source prefilters for Transpile - #889
Conversation
…ranspile Transpile's operator, || and string-literal passes each walked every exported field of every node by reflection. They now share per-type traversal plans (pkg/internal/reflplan, cached in a sync.Map) that skip fields whose static type cannot hold an interface, so strings, numbers, positions and quote metadata are never visited. The operator walk reuses pooled scratch (bounded, cleared before reuse), the per-dialect-pair rule lists are built once, and source-byte prefilters skip the || rules, string-literal re-rendering and data-type requoting when the SQL has no byte that could need them. Output and errors are byte-identical to before on 955,476 differential cases. BenchmarkTranspile: 5.18 µs / 52 allocs -> 2.68 µs / 43 allocs; wide OR/AND expressions -68%, set-operation LIMIT -57%. Tests: plan unit tests (cycles, maps, embedded, concurrency), a coverage guard against an independent reachability check, a plan-vs-naive walk over the real-world corpus, prefilter equivalence across all 81 dialect pairs, cache/pool hygiene, and a SelectOps benchmark. 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 34s —— View job Review of PR #889: cached reflection plans and source prefiltersVerdict: Approve in spirit, with a few non-blocking notes. I read the diff of the core files ( Done well
Notes (non-blocking)
Test coverageThe coverage looks strong: unit tests for cycles, maps and zero-length arrays, a concurrent SecurityI found nothing concerning. The cache keys are |
…check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 21s —— View job Review of PR #889: cached reflection plans and source prefiltersI read the core diff again on this push ( Verdict: No blocking issues. The design is sound and the invariants are documented. I have one small hygiene fix and a few suggestions. What looks right
Findings
Test coverageCoverage is strong: the reflplan unit tests, the AST reachability guard, the plan versus naive walk comparison, prefilter equivalence, the parallel SecurityI found no concerns. The caches are keyed by |
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 #889: cached reflection plans and source prefiltersI re-read Verdict: No blocking issues. Previous finding is fixedThe panic-path scratch leak I raised earlier is resolved by Remaining suggestions (non-blocking)
Summary
|
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 #889: cached reflection plans and source prefiltersI re-read Verdict: No blocking issues. Resolved since the last review
Remaining suggestions (non-blocking)
Summary
|
* docs(release): fold #888 and #889 into v1.17.0, date 2026-10-31 Tagging main ships the Transpile speed-up and playground fixes, so their entries move from [Unreleased] into 1.17.0, the Transpile cost note is updated (2.7 µs vs 2.0 µs in v1.16.0), and the 1.17.0 compare link is added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2 * fix(vscode): override vscode-languageclient's minimatch to 11 (CVE-2026-118764) Trivy flags minimatch 5.1.9 (fixed in 11.0.1), which vscode-languageclient 9 bundles into the extension. The client only uses minimatch.Minimatch, which minimatch 11 still exports, so a scoped override is API-compatible; the extension compiles and a Minimatch glob resolved through the client matches. 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>
Summary
v1.17.0's correctness passes made
transpiler.Transpile~2.6x slower than v1.16.0 (recorded in the v1.17.0 CHANGELOG). This restores most of it with byte-identical behaviour.pkg/internal/reflplan(new, internal): per-reflect.Typetraversal plans cached in async.Map. A least fixpoint marks which types can transitively hold an interface; plans list only those exported fields, in declaration order. Strings, numbers,models.Location, quote metadata etc. are never visited.ast.RetargetOperators,rules.PipesOrToKeywordOr, the||→CONCATrewrite andretargetStringLiterals. Noreflect.Type.Fieldcalls in the hot path.sync.Pool, dropped when over 4096 entries; frames are zeroed as they pop so pooled scratch never references a released AST.Transpile(each documented with its proof): no|byte → the two||rules are left out; no',",$and no non-ASCII byte → string-literal re-rendering is skipped; no",`,[and no non-ASCII byte →RestyleDataTypesis skipped.SetNameQuoteStylealways runs.sync.Once, bounded to the known dialects; unknown names fall back).RulesForstill returns a fresh slice.Design came from a workflow of three independent approaches (cached plans, prefilters/fusion, typed walker) judged on measured prototypes; implemented with Codex, reviewed by go-reviewer (no blocking issues; its medium/low items are fixed here).
Benchmarks (Apple M4,
-count=8, benchstat vsfda9a5ef, all p=0.000)||Test Plan
fda9a5efon 955,476 cases (corpus statements × dialect pairs + edge cases)task check(fmt, vet, golangci-lint, full race suite) andtask test:cbindingOf); AST coverage guard comparing plans with an independent reachability search; plan-driven vs naive walk overtestdata/realworld; prefilter on/off equivalence across all 81 dialect pairs plus string-opener pins; rule-cache immutability; parallel Transpile under-race; scratch reset / popped-frame invariants; 490k chain followed by a small transpileTestTranspileDeepChains, >512 nesting error,TestRealWorldCorpus, pool hygieneBreaking Changes
None. No public API change;
pkg/internal/reflplanis internal. CHANGELOG entry will be added once the v1.17.0 release PR (#877) lands, to avoid conflicting with its CHANGELOG rewrite.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2