Skip to content

Reduce timer-enabled runtime overhead in direct .cod runs and cross benchmarks#107

Merged
DanexCodr merged 3 commits into
mainfrom
copilot/run-cod-tests-and-fix-bottlenecks
Apr 18, 2026
Merged

Reduce timer-enabled runtime overhead in direct .cod runs and cross benchmarks#107
DanexCodr merged 3 commits into
mainfrom
copilot/run-cod-tests-and-fix-bottlenecks

Conversation

Copilot AI commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

The issue was high execution overhead when running non-Invalid .cod tests directly (not parity) with timers enabled, and similarly inflated runtime in cross benchmarks under timer-enabled modes.
This change targets timer hot paths so profiling remains available while avoiding timer bookkeeping/log amplification in tight interpreter loops.

  • Timer hot-path redesign (DebugSystem)

    • Replaced single-entry level timer maps with per-thread LIFO stacks keyed by operation name.
    • Supports nested same-name timers correctly without generating unique timer IDs per invocation.
    • Added explicit per-thread timer-state cleanup when debug level is turned off.
  • Hot-path timer call simplification

    • Removed per-call timer-name construction (threadId + nanoTime) from perf helpers in:
      • ASTVisitor
      • ExecutionContext
      • ExpressionHandler
      • ImportResolver
      • NaturalArray
    • All now use stable operation names for start/stop in level-based timers.
  • High-frequency timer level adjustment

    • Moved expression.handleBinaryOp perf timing from DEBUG to TRACE.
    • Keeps fine-grained visibility available when explicitly requested, while preventing debug-mode log/timer saturation in arithmetic-heavy code.
// Before
String timer = startPerfTimer(DebugSystem.Level.DEBUG, "expression.handleBinaryOp");

// After
String timer = startPerfTimer(DebugSystem.Level.TRACE, "expression.handleBinaryOp");

@DanexCodr DanexCodr marked this pull request as ready for review April 18, 2026 10:00
@DanexCodr DanexCodr merged commit ed5de15 into main Apr 18, 2026
@DanexCodr DanexCodr deleted the copilot/run-cod-tests-and-fix-bottlenecks branch May 3, 2026 10:46
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