perf(engine): reclaim deleted branch forks in the background - #542
Open
azimafroozeh wants to merge 1 commit into
Open
perf(engine): reclaim deleted branch forks in the background#542azimafroozeh wants to merge 1 commit into
azimafroozeh wants to merge 1 commit into
Conversation
azimafroozeh
marked this pull request as ready for review
August 21, 2026 21:05
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
What & why
Follow-up to #540. That PR made branch merge faster; this one makes branch delete faster. Both respond to the same report of merge and delete timeouts.
Deleting a branch does two things. Removing the branch ref from the manifest is the logical deletion: one small write, after which no read can see the branch. Reclaiming the per-dataset Lance forks the branch owned is physical cleanup: a serial chain of object-store round trips that grows with the number of datasets the branch wrote.
Before this PR the response waited for both. Now
branch_deletereturns at the ref removal, and the fork reclaim continues in a background task. The task holds the request's schema, branch, and dataset gates until it finishes, so every concurrent branch control serializes behind the reclaim exactly as before. Only the caller stops waiting.Omnigraph::wait_for_fork_reclaims()joins pending reclaims. The CLI calls it before process exit, the server after graceful drain, tests for determinism.Measured with a delete-scenario A/B on the #537 bench harness (release builds, warm local FS, 5-rep medians, T = datasets the branch forked):
Response plus convergence time is conserved across the two trees: the reclaim moved, it did not shrink. The effect grows on object storage, where every serial round trip costs real network latency. The delete scenario is the checked-in instrument and follows as its own PR on the #537 harness; none ships here.
Backing issue / RFC
Checklist
Local verification
cargo test --workspace --no-fail-fast(failpoints superset): green except the pre-existing sandbox-onlyexternal_blob_file_policy_rejects_special_filescargo clippy --workspace --all-targets(CI shape) andcargo fmt --all --check: cleanNotes for reviewers
cleanup's ref-listing sweep and converges on the next same-name create, the same state a crash after the ref delete leaves. The warn message names both paths.cleanupremains the backstop either way.tokio::spawn; non-tokio embedders fall back to inline reclaim.Greptile Summary
The PR moves branch-delete fork reclamation behind the manifest authority flip, allowing deletion responses to return before physical cleanup while preserving serialization through carried write-queue gates.
Confidence Score: 5/5
The PR appears safe to merge, with background reclamation preserving the existing authority and serialization contracts.
The manifest remains the logical deletion commit point, same-process conflicting operations remain excluded by the carried gates, and production exit paths join registered reclaim tasks after branch-delete dispatch or graceful request drain.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant Engine participant Manifest participant Reclaim as Background reclaim participant Lance Client->>Engine: branch_delete(name) Engine->>Engine: Acquire schema, branch, and dataset gates Engine->>Manifest: Remove authoritative branch ref Manifest-->>Engine: Logical deletion committed Engine->>Reclaim: Spawn cleanup carrying gates Engine-->>Client: Delete succeeded Reclaim->>Lance: Remove owned dataset forks alt Reclaim completes Lance-->>Reclaim: Forks removed else 600-second watchdog expires Reclaim->>Reclaim: Abandon cleanup and log warning end Reclaim->>Reclaim: Release carried gatesReviews (1): Last reviewed commit: "perf(engine): reclaim deleted branch for..." | Re-trigger Greptile
Context used (3)