Skip to content

Compile: record the phase split in the activity log — stop guessing where 45s goes - #685

Merged
rbuergi merged 1 commit into
mainfrom
feat/compile-phase-timings
Jul 28, 2026
Merged

rbuergi merged 1 commit into
mainfrom
feat/compile-phase-timings

Conversation

@rbuergi

@rbuergi rbuergi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Why this exists

Three fixes were attempted for the 2026-07-27 outage tonight. All three were guesses at a mechanism, because nothing measures the compile's internals. The activity log shows 45.20 s between "Invoking compiler…" and the source queries resolving, against 2.83 s of Roslyn — but why was reconstructable only by subtracting microsecond timestamps and then inventing a story to fit.

Every story was wrong:

guess disproved by
the cached synced query stalls (#682) the uncached probe never fired in production — zero log lines
a lost Initial waits for the 45 s heartbeat (#684) starting the heartbeat early changed nothing: 48 s before, 57 s after
15 s GetMeshNode + 30 s SnapshotSources = 45 s Loki shows those 15 s stalls on LocalSyncDemo/_Sync/party-1 (82×), never on the compile path

What it adds

Three clocks, written into the compile's own ActivityLog, so a single get @{Type}/_Activity/compile-… shows the split with no log correlation and no arithmetic:

⏱ NodeType definition resolved in {ms}ms (ok | NULL — the read stalled or the node is absent);
  source-freshness scan {ms}ms.
⏱ Source discovery took {ms}ms (synced query | caller-supplied override) —
  everything below this line is Roslyn.

The null-definition case is called out explicitly because that read is a bounded 15 s EmitNull: on a stall it yields null and the compile proceeds against a null definition — which the surrounding comment already admits is "a silently wrong compile". If that is what's happening on memex, this line says so outright.

Scope

Logging only, no behaviour change. 647/647 Graph tests pass.

What to do with it

Deploy, run one compile of Store/Coupon (the type measured all night — 23 Code nodes across four types via shared=), and read the activity node. The 45 s is in exactly one of three places, and this says which. Then fix that, with evidence instead of a fourth story.

🤖 Generated with Claude Code

…here 45s goes

Three fixes were attempted for the 2026-07-27 outage and all three were guesses at a
mechanism, because nothing measures the compile's internals. The activity log showed
45.20s between "Invoking compiler…" and the source queries resolving, against 2.83s
of Roslyn, but WHY was reconstructable only by subtracting microsecond timestamps and
then inventing a story to fit. Each story was wrong:

  - "the cached synced query stalls"  → the uncached probe never fired (#682)
  - "a lost Initial waits for the 45s heartbeat" → starting the heartbeat early
    changed nothing measurable in production (#684: 48s before, 57s after)
  - "15s GetMeshNode + 30s SnapshotSources = 45s" → Loki shows those 15s stalls
    happening on LocalSyncDemo/_Sync/party-1, never on the compile path

So measure instead. Three clocks, written into the compile's OWN ActivityLog, so one
`get @{Type}/_Activity/compile-…` shows the split with no log correlation:

  ⏱ NodeType definition resolved in {ms}ms (ok | NULL — the read stalled …);
    source-freshness scan {ms}ms.
  ⏱ Source discovery took {ms}ms (synced query | caller-supplied override) —
    everything below this line is Roslyn.

The null-definition case is called out explicitly because that read is a bounded 15s
EmitNull: on a stall it yields null and the compile proceeds against a null
definition, which the code already documents as "a silently wrong compile".

Logging only — no behaviour change. 647/647 Graph tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 02:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds phase-level timing instrumentation to MeshNodeCompilationService so compile activities record where time is spent (NodeType definition resolution, source freshness scan, and source discovery), making 45s+ stalls diagnosable directly from the per-compile ActivityLog.

Changes:

  • Record definition-resolution and source-freshness timings into the compile ActivityLog.
  • Record source-discovery timing (synced query vs caller override) into the compile ActivityLog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +713 to +716
var discoveryLog = AppendInfo(log,
$"⏱ Source discovery took {discoveryClock.ElapsedMilliseconds}ms "
+ $"({(sourcesOverride is not null ? "caller-supplied override" : "synced query")}) — "
+ "everything below this line is Roslyn.");
@github-actions

Copy link
Copy Markdown
Contributor

Test Results (shard 0)

959 tests  ±0   953 ✅ ±0   5m 2s ⏱️ +23s
  5 suites ±0     6 💤 ±0 
  5 files   ±0     0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (shard 3)

   12 files  ±0     12 suites  ±0   4m 32s ⏱️ +18s
  974 tests ±0    970 ✅ ±0  4 💤 ±0  0 ❌ ±0 
1 037 runs  ±0  1 033 ✅ ±0  4 💤 ±0  0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (shard 4)

1 997 tests  ±0   1 809 ✅ ±0   5m 33s ⏱️ +22s
   12 suites ±0     188 💤 ±0 
   12 files   ±0       0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (shard 5)

1 142 tests  ±0   1 141 ✅ ±0   6m 19s ⏱️ -1s
   12 suites ±0       1 💤 ±0 
   12 files   ±0       0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (shard 2)

1 129 tests  ±0   1 026 ✅ ±0   5m 19s ⏱️ -6s
   10 suites ±0     103 💤 ±0 
   10 files   ±0       0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (shard 1)

1 183 tests  ±0   1 182 ✅ ±0   7m 52s ⏱️ +38s
   10 suites ±0       1 💤 ±0 
   10 files   ±0       0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   61 files  ±0     61 suites  ±0   34m 39s ⏱️ + 1m 34s
7 384 tests ±0  7 081 ✅ ±0  303 💤 ±0  0 ❌ ±0 
7 447 runs  ±0  7 144 ✅ ±0  303 💤 ±0  0 ❌ ±0 

Results for commit 9b09832. ± Comparison against base commit aeb2bf0.

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