typing/perf 1/4: counters, phase profiler, scaling bench harness - #80
Open
Felipe705x wants to merge 1 commit into
Open
typing/perf 1/4: counters, phase profiler, scaling bench harness#80Felipe705x wants to merge 1 commit into
Felipe705x wants to merge 1 commit into
Conversation
Instrumentation pass before optimizing the typechecker (measure first): - src/typing/stats.rs: thread-local always-on counters for the hot primitives (refine calls + schema entries scanned per arm, refine_to_nodes, env meet/union/outer_join/to_group, PathType::meet). reset()/snapshot() around a region; increments are noise next to the schema scans they count. - Typechecker::enable_profiling(): per-phase wall split of check_query (pattern / rep-checks / group_by / returns / order_by) behind an Option<Box<PhaseProfile>> that costs one branch per phase when off. - pattern_typecheck: adds generated scaling families against the LDBC schema (chain_N, chain_dir_N, anydir_N, union_W, repeat_bounded, subq, anon_unlabeled_N), a --star-schema small-schema control, per-case counter + phase columns in the CSV, batch timing for sub-2us cases, and a per-case iteration budget so pathological cases cannot stall the run. Baseline (LDBC SF0.1 schema, 11 node / 25 edge entries, warm): - labeled chains scale linearly: ~28 us/hop (chain_16 = 448 us), of which ~23 us/hop is schema scanning (star-schema control: 5 us/hop). - refine dominates labeled patterns: chain_16 = 65 refine calls / 400 edge entries scanned. - pathological find: unlabeled chains blow up exponentially in structure SIZE with linear call counts (anon_unlabeled_8 = 32 ms, anon_unlabeled_16 = 23.3 s per check_query) -- PathType carries the full prefix history per union arm, so width multiplies per hop by the compatible-schema-entry count. Co-Authored-By: Claude Fable 5 <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.
First of a stacked series optimizing the static typechecker. This PR adds measurement only — no behavior change.
src/typing/stats.rs: always-on thread-local counters for the checker's hot primitives (refine calls + schema entries scanned, env meet/union/outer-join/to-group, PathType meets).Typechecker::enable_profiling(): opt-in per-phase wall split ofcheck_query(one branch per phase when off).pattern_typecheck: generated scaling families (chain_N,chain_dir_N,anydir_N,union_W,anon_unlabeled_N, repeats, subqueries),--star-schemacontrol, per-case counter + phase CSV columns, batch timing for sub-2 µs cases, per-case iteration budget.Baseline captured (LDBC SF0.1 schema, 11 node / 25 edge entries):
()-[]->()×16 measured 23.3 s per check_query (N=8: 32 ms). Cause analysis in PR 4/4.Merge gate: none beyond review — measurement-only.
🤖 Generated with Claude Code