Skip to content

Add --debug-stats mode for runtime performance analysis#632

Merged
stephenamar-db merged 1 commit intomasterfrom
stephenamar-db/debug-stats
Mar 4, 2026
Merged

Add --debug-stats mode for runtime performance analysis#632
stephenamar-db merged 1 commit intomasterfrom
stephenamar-db/debug-stats

Conversation

@stephenamar-db
Copy link
Collaborator

Introduces a --debug-stats CLI flag that prints counters and timing to stderr after evaluation: lazy creation counts, function/builtin call counts, comprehension iterations, unique import counts (with cache hit tracking), per-phase timing (parse, eval, materialize), and JVM heap usage. Counters use stable snake_case labels for machine parsing.

The DebugStats class is threaded through Interpreter -> Evaluator with null-check guards so there is zero overhead when the flag is not set. Parse counting/timing is handled by CountingParseCache wrapping the existing ParseCache.

Introduces a --debug-stats CLI flag that prints counters and timing to
stderr after evaluation: lazy creation counts, function/builtin call
counts, comprehension iterations, unique import counts (with cache hit
tracking), per-phase timing (parse, eval, materialize), and JVM heap
usage. Counters use stable snake_case labels for machine parsing.

The DebugStats class is threaded through Interpreter -> Evaluator with
null-check guards so there is zero overhead when the flag is not set.
Parse counting/timing is handled by CountingParseCache wrapping the
existing ParseCache.
@stephenamar-db stephenamar-db merged commit b78cff1 into master Mar 4, 2026
12 checks passed
@stephenamar-db stephenamar-db deleted the stephenamar-db/debug-stats branch March 4, 2026 21:38

# Check formatting without changing files
./mill __.checkFormat
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User can install scalafmt native too, which should be faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants