Skip to content

Conversation

@bosconi
Copy link
Member

@bosconi bosconi commented Jan 14, 2026

Summary

  • Move CPU-intensive sorting work in ConsolidationPart::from_encoded to the IsolatedRuntime
  • This prevents runtime stalls that could cause heartbeat tasks to miss deadlines, resulting in persist reader lease expirations
  • Follows the same pattern used for batch encoding in batch.rs

Motivation

The Consolidator's sorting operation can be CPU-intensive for large parts that need reconsolidation. When this runs on the main tokio runtime, it can block other tasks including the heartbeat task responsible for keeping reader leases alive.

Test plan

  • cargo check -p mz-persist-client passes
  • cargo test -p mz-persist-client iter:: passes (2/2 tests)
  • cargo test -p mz-persist-client --lib passes (121/121 tests)

Generated with Claude Code

The `ConsolidationPart::from_encoded` function performs CPU-intensive
sorting work that was previously running synchronously on the main
runtime. This could cause runtime stalls that prevent heartbeat tasks
from running, leading to persist reader lease expirations.

This change adds `from_encoded_async` that spawns the sorting work on
the IsolatedRuntime, following the pattern used for batch encoding.

Changes:
- Add `isolated_runtime` field to `Consolidator` struct
- Add `from_encoded_async` method that sorts on isolated runtime
- Update `unblock_progress` to use async version
- Add manual Clone impl for StructuredSort (no K: Clone, V: Clone needed)
- Update all callers to pass isolated_runtime

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@bosconi bosconi requested a review from a team as a code owner January 14, 2026 11:56
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.

1 participant