Skip to content

Conversation

markfields
Copy link
Member

@markfields markfields commented Aug 29, 2025

Description

What's changed

No longer call bind in the FluidSerializer during summarization. Instead, assert the two invariants discussed below which prove that bind would be a no-op.

Background

During Summarization, we can be sure of these two facts:

  1. Each DDS being summarized is attached
  2. Any handle stored has already been bound

(1) is true because of asserts and errors in ChannelCollection and DataStoreRuntime

(2) is true because the Summarizer only runs on attached containers, and the source DDS is attached (see 1), so its outbound handles would have already been bound.

And besides all this -- Summarizer shouldn't even have local changes! But we know there are cases where it does so it's good to be sure.

Reviewer Guidance

Mostly depending on existing test coverage to prove it's ok. Did not come up with specific new tests to add, but open to suggestions.

@github-actions github-actions bot added area: dds Issues related to distributed data structures area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch labels Aug 29, 2025
@github-actions github-actions bot removed the area: tests Tests to add, test infrastructure improvements, etc label Sep 2, 2025
@markfields markfields marked this pull request as ready for review September 2, 2025 22:39
@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 22:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes handle serialization during summarization by skipping the bind operation when it's guaranteed to be a no-op. The change leverages the fact that during summarization, all DDSes are attached and handles are already bound.

  • Introduces a forSummarizer flag to FluidSerializer to control bind behavior
  • Adds assertions to verify the invariants that make bind unnecessary during summarization
  • Creates a dedicated serializer instance for summarization operations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/dds/shared-object-base/src/sharedObject.ts Creates a new FluidSerializer instance with forSummarizer flag for summarization
packages/dds/shared-object-base/src/serializer.ts Adds forSummarizer parameter and conditional bind logic with assertions

Comment on lines +232 to +236
assert(bind.isAttached, "Expected bind source to be attached in the Summarizer");
assert(
handle.isAttached,
"Expected target to have been already attached (via binding to source)",
);
Copy link
Preview

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

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

The assert statements should use string literals for error messages instead of descriptive text. Consider using hex codes or simple string literals as specified in the coding guidelines.

Copilot generated this review using guidance from repository custom instructions.

@markfields markfields changed the title improve(handles): Skip no-op bind step when serializing handles during summarization improve(handles): Skip no-op bind step when serializing handles during regular summarization Sep 2, 2025
Copy link
Contributor

@jzaffiro jzaffiro left a comment

Choose a reason for hiding this comment

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

Changes make sense to me

@@ -225,7 +228,16 @@ export class FluidSerializer implements IFluidSerializer {
handle: IFluidHandleInternal,
bind: ISharedObjectHandle,
): ISerializedHandle {
bind.bind(handle);
if (this.forSummarizer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider creating a separate serializer for summarizer like the GCHandleVisitor. IMO, that is much cleaner and is similar to existing patterns.

@@ -225,7 +228,16 @@ export class FluidSerializer implements IFluidSerializer {
handle: IFluidHandleInternal,
bind: ISharedObjectHandle,
): ISerializedHandle {
bind.bind(handle);
if (this.forSummarizer) {
assert(bind.isAttached, "Expected bind source to be attached in the Summarizer");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be safe. But should we consider adding this behind a feature flag or something to be sure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds Issues related to distributed data structures base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants