feat(metrics): record per-snapshot dirty/empty/total bytes at creation#2649
Conversation
Three histograms recorded once per Pause: - orchestrator.sandbox.snapshot.diff.bytes - orchestrator.sandbox.snapshot.diff.ratio_bp (basis points, 10000=100%) - orchestrator.sandbox.snapshot.total.bytes Attributes: file_type=memfile|rootfs, kind=dirty|empty, use_case=pause|build. Use-case lets us split the regular pause path from template-build's PauseAndUpload so a change to FPR/FPH/reclaim can be evaluated in isolation per call site.
PR SummaryMedium Risk Overview Reviewed by Cursor Bugbot for commit 1ab4253. Bugbot is set up for automated code reviews on this repo. Configure here. |
❌ 10 Tests Failed:
View the full list of 16 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Code Review
The diffStatsFromMetadata function in packages/orchestrator/pkg/sandbox/sandbox.go accesses the Dirty and Empty bitmaps without checking for nil pointers, which could cause a panic if a provider returns metadata with uninitialized bitmaps. Adding explicit nil checks before calling GetCardinality ensures the stats calculation is safe and prevents potential service instability when diff information is incomplete.
Pass useCase to Sandbox.Pause and have it call recordSnapshotDiff right after each per-pause DiffMetadata is produced — memfile inside Pause, rootfs inside pauseProcessRootfs (where the rootfs DiffMetadata lives). No Snapshot field, no helper struct, no extra return values.
There was a problem hiding this comment.
An organization admin can view or raise the cap at claude.ai/admin-settings/claude-code. The cap resets at the start of the next billing period.
Once the cap resets or is raised, reopen this pull request to trigger a review.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Wrong use case constant in resume-build tool
- Changed line 643 from SnapshotUseCasePause to SnapshotUseCaseBuild to correctly classify template build operations in metrics.
Or push these changes by commenting:
@cursor push 919a0b87ef
Preview (919a0b87ef)
diff --git a/packages/orchestrator/cmd/resume-build/main.go b/packages/orchestrator/cmd/resume-build/main.go
--- a/packages/orchestrator/cmd/resume-build/main.go
+++ b/packages/orchestrator/cmd/resume-build/main.go
@@ -640,7 +640,7 @@
// Pause and create snapshot
pauseStart := time.Now()
- snapshot, err := sbx.Pause(ctx, newMeta, sandbox.SnapshotUseCasePause)
+ snapshot, err := sbx.Pause(ctx, newMeta, sandbox.SnapshotUseCaseBuild)
pauseDur := time.Since(pauseStart)
totalDur := time.Since(t0)You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 2fedc0d. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 237b7a2932
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
#2649) Per-snapshot histograms (full/empty/total bytes + ratio %) recorded inside Sandbox.Pause, attributed by file_type (memfile/rootfs), kind (full/empty), and use_case (pause/build), so we can see how FPR/FPH/reclaim affect snapshot composition and tell pause-time samples from template-build samples apart.


Per-snapshot histograms (full/empty/total bytes + ratio %) recorded inside Sandbox.Pause, attributed by file_type (memfile/rootfs), kind (full/empty), and use_case (pause/build), so we can see how FPR/FPH/reclaim affect snapshot composition and tell pause-time samples from template-build samples apart.