Skip to content

perf(state_manager): [DSM-145] Compute the manifest concurrently with validation#10798

Open
alin-at-dfinity wants to merge 1 commit into
masterfrom
alin/DSM-145-parallel-validate_eq-and-manifest
Open

perf(state_manager): [DSM-145] Compute the manifest concurrently with validation#10798
alin-at-dfinity wants to merge 1 commit into
masterfrom
alin/DSM-145-parallel-validate_eq-and-manifest

Conversation

@alin-at-dfinity

Copy link
Copy Markdown
Contributor

Move manifest computation onto a dedicated thread so it overlaps ValidateReplicatedStateAndFinalize instead of running after it on the tip thread.

The ComputeManifest request is enqueued on the tip channel ahead of validation and forwarded by the tip thread to the manifest thread only onceTipToCheckpointAndSwitch has finished serializing the checkpoint's protos. The computed BundledManifest is handed back and published from a paired WaitForManifest request enqueued on the tip channel after validation, so the root hash is only visible to Consensus once the checkpoint is verified.

At 200k idle canisters, the manifest (~28s to root hash) now runs entirely within the validation window (~31s), cutting batch->root-hash from ~44s to ~34s while also moving the post-publish rehash off the critical path.

Supporting changes:

  • files_with_sizes skips checkpoint marker files during the directory walk. They are never part of a manifest, and skipping them by name avoids stating a marker that concurrent checkpoint finalization is removing, which would otherwise fail manifest computation. This makes the previous post-hoc marker exclusion in compute_manifest unnecessary.
  • flush_tip_channel forwards its Wait barrier to the manifest thread as well, so it still waits for all outstanding checkpoint work -- including the post-publish rehash -- to drain.

… validation

Move manifest computation onto a dedicated thread so it overlaps `ValidateReplicatedStateAndFinalize` instead of running after it on the tip thread.

The `ComputeManifest` request is enqueued on the tip channel ahead of validation and forwarded by the tip thread to the manifest thread only once`TipToCheckpointAndSwitch` has finished serializing the checkpoint's protos. The computed `BundledManifest` is handed back and published from a paired `WaitForManifest` request enqueued on the tip channel after validation, so the root hash is only visible to Consensus once the checkpoint is verified.

At 200k idle canisters, the manifest (~28s to root hash) now runs entirely within the validation window (~31s), cutting batch->root-hash from ~44s to ~34s while also moving the post-publish rehash off the critical path.

Supporting changes:

- `files_with_sizes` skips checkpoint marker files during the directory walk. They are never part of a manifest, and skipping them by name avoids `stat`ing a marker that concurrent checkpoint finalization is removing, which would otherwise fail manifest computation. This makes the previous post-hoc marker exclusion in `compute_manifest` unnecessary.
- `flush_tip_channel` forwards its `Wait` barrier to the manifest thread as well, so it still waits for all outstanding checkpoint work -- including the post-publish rehash -- to drain.
@alin-at-dfinity
alin-at-dfinity requested a review from a team as a code owner July 16, 2026 14:06
@github-actions github-actions Bot added the perf label Jul 16, 2026
@zeropath-ai

zeropath-ai Bot commented Jul 16, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 7c1a82d.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/state_manager/src/lib.rs
    Introduce and document tip_channel and manifest-related workflow; add manifest-thread handling and WaitForManifest flow; adjust CreateCheckpointResult to include tip_requests and update state_metadata comments and fields
Enhancement ► rs/state_manager/src/manifest.rs
    Skip unverified/state-sync checkpoint markers during directory listing; adjust compute_manifest to work with marker-skipping and clarify manifest computation behavior
Enhancement ► rs/state_manager/src/tip.rs
    Add manifest thread (ComputeManifest and WaitForManifest handling); update TipRequest variants and add manifest_thread logic; adjust ComputeManifest and WaitForManifest flow; enable publishing manifest after verification
Enhancement ► rs/state_manager/tests/state_manager.rs
    Add test concurrently_computed_manifest_covers_the_whole_checkpoint to validate manifest computation timing relative to checkpoint verification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant