Skip to content

feat: Write protobufs asynchronously [MR-355] #4792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

pakhomov-dfinity
Copy link
Contributor

@pakhomov-dfinity pakhomov-dfinity commented Apr 11, 2025

During checkpointing we serialize protobufs of canisters and snapshots on the critical path, even though we don't need them to continue execution. In this change we serialize them in the background in parallel with execution.
Their values are used to validate that the serialized data matches data in memory (ValidateEq). This step is a background operation.

@github-actions github-actions bot added the feat label Apr 11, 2025
@pakhomov-dfinity pakhomov-dfinity marked this pull request as ready for review April 11, 2025 16:04
@pakhomov-dfinity pakhomov-dfinity requested a review from a team as a code owner April 11, 2025 16:04
@pakhomov-dfinity pakhomov-dfinity changed the title feat: Write protobufs asynchronously feat: Write protobufs asynchronously [MR-355] Apr 11, 2025
Comment on lines +1077 to +1078
assert!(execution_state.wasm_memory.page_map.page_delta_is_empty());
assert!(execution_state.stable_memory.page_map.page_delta_is_empty());
Copy link
Contributor

@ShuoWangNSL ShuoWangNSL Apr 11, 2025

Choose a reason for hiding this comment

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

These assertions as well as the one for wasm_chunk_store hold because we have flushed pagemaps and stripped page deltas earlier, right?

If the calls of persist_delta() here are redundant before this PR., shall we make the changes in a separate small PR? I am asking because this PR makes quite fundamental changes, and it will make it easier to reason about what are changed by async writing.

Ok(())
}

fn serialize_canister_to_tip(
Copy link
Contributor

@ShuoWangNSL ShuoWangNSL Apr 11, 2025

Choose a reason for hiding this comment

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

Now, serialize_canister_to_tip is moved to after creating checkpoint and only contains writing canister pbufs.
However,serialize_snapshot_to_tip still contains writing wasm binaries and persisting page deltas. Shall we treat snapshots in the same way as canisters here, i.e. moving writing wasm binaries before creating checkpoint and changing persisting page deltas to just assertions assuming that they are also redundant?

My other PR #4777 fixes a similar issue about for wasm binaries of canister snapshots.

Ok(())
}

fn serialize_canister_to_tip(
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think this name (along with serialize_to_tip and serialize_snapshot_to_tip) should be more explicit that it only writes protobufs.

/// 1) `tip` and `layout` mut have exactly the same set of canisters.
/// 2) The page deltas must be empty in `tip`
/// 3) The memory sizes must match.
fn switch_to_checkpoint(
Copy link
Member

Choose a reason for hiding this comment

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

Careful about moving this, Shuo's PR modifies this function, and will very likely go in before your PR. You don't want to undo his fix accidentally.

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

Successfully merging this pull request may close these issues.

3 participants