Merged
Conversation
Profiling showed 53% of heap allocations (6.7 MB / 12.7 MB) came from three redundant parse operations. This commit eliminates all three: 1. YAML double-parse (31.8% of heap): process_node_dir() already reads YAML to probe the kind field, then discards it. Loaders re-read and re-parse the same file. Fix: add load_from_str() variants and pass the already-read content through to loaders. 2. FeatherFlowProvider rebuilt per model (11.6%): propagate_schemas() constructed a new provider for every model in topo order, rebuilding Arrow schema maps from scratch each time (O(N²)). Fix: build once before the loop, incrementally insert_schema() after each model. 3. SQL double-parse in qualify (9.1%): qualify_table_references() re-parses SQL that was already parsed in compile_model_phase1(). Fix: add qualify_statements() that operates on the existing AST, store parsed statements in CompileOutput. Benchmarks: project_load -13.6%, propagate_schemas -5.2%, qualify_table_references -4.5%, dag_topological_sort -10.1%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process_node_dir()already reads YAML to probe thekindfield, then discards content. Addedload_from_str()variants toModelSchema,SourceFile, andFunctionDefso loaders reuse the already-read content instead of re-reading from disk and re-parsing.propagate_schemas()was rebuilding a newFeatherFlowProvider(converting all Arrow schemas) for every model in topo order — O(N²). Now builds once before the loop and callsinsert_schema()incrementally — O(N).qualify_table_references()re-parsed SQL that was already parsed incompile_model_phase1(). Addedqualify_statements()that operates directly on the existing AST.CompileOutputnow carries parsed statements through to the qualification phase.Benchmark Results
All improvements confirmed statistically significant by criterion (p < 0.05).
Test plan
make test— all 1,092 tests passmake bench— criterion benchmarks confirm improvementsmake ci-e2e— end-to-end test harnessmake profile-memory— verify heap reduction via dhat🤖 Generated with Claude Code