Skip to content
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

Process ops by batches in remoteMessageProcessor and pendingStateManager #21785

Merged
merged 5 commits into from
Jul 8, 2024

Conversation

dannimad
Copy link
Contributor

@dannimad dannimad commented Jul 8, 2024

In order to be able to recognize a batch that becomes empty on resubmit, we need to process them by batch instead of by individual op. This will help to make subsequent changes that will allow flushing on empty batches.

@github-actions github-actions bot added area: runtime Runtime related issues base: main PRs targeted against main branch labels Jul 8, 2024
@dannimad dannimad marked this pull request as ready for review July 8, 2024 19:30
@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Jul 8, 2024

@fluid-example/bundle-size-tests: +2.39 KB
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 455.96 KB 456.53 KB +585 Bytes
azureClient.js 553.7 KB 554.28 KB +599 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 257.17 KB 257.72 KB +564 Bytes
fluidFramework.js 388.04 KB 388.06 KB +14 Bytes
loader.js 134.1 KB 134.11 KB +14 Bytes
map.js 42.17 KB 42.17 KB +7 Bytes
matrix.js 145.43 KB 145.44 KB +7 Bytes
odspClient.js 521.46 KB 522.04 KB +599 Bytes
odspDriver.js 96.94 KB 96.96 KB +21 Bytes
odspPrefetchSnapshot.js 42.23 KB 42.24 KB +14 Bytes
sharedString.js 162.51 KB 162.52 KB +7 Bytes
sharedTree.js 378.51 KB 378.51 KB +7 Bytes
Total Size 3.25 MB 3.25 MB +2.39 KB

Baseline commit: 7edcd04

Generated by 🚫 dangerJS against eeb738b

@@ -67,13 +67,14 @@ export class RemoteMessageProcessor {
* 3. If grouped, ungroup the message
* For more details, see https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/src/opLifecycle/README.md#inbound
*
* @returns the unchunked, decompressed, ungrouped, unpacked SequencedContainerRuntimeMessages encapsulated in the remote message.
* @returns all the unchunked, decompressed, ungrouped, unpacked InboundSequencedContainerRuntimeMessage from a single batch
* or undefined if the batch is not yet complete.
* For ops that weren't virtualized (e.g. System ops that the ContainerRuntime will ultimately ignore),
* a singleton array [remoteMessageCopy] is returned
*/
public process(remoteMessageCopy: ISequencedDocumentMessage):
Copy link
Member

Choose a reason for hiding this comment

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

May not matter, but I think this type could also be InboundSequencedContainerRuntimeMessage.

message: InboundSequencedContainerRuntimeMessage;
localOpMetadata: unknown;
}[] {
return batch.map((message) => ({
Copy link
Member

Choose a reason for hiding this comment

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

Future: we'll be able to move maybeProcessBatchStart and maybeProcessBatchEnd to the start/end of this function an drop the maybe :)

Copy link
Member

@markfields markfields left a comment

Choose a reason for hiding this comment

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

Didn't look closely at tests, but the change looks good! Exciting!

@dannimad dannimad enabled auto-merge (squash) July 8, 2024 22:27
@dannimad dannimad merged commit 73b7b99 into microsoft:main Jul 8, 2024
30 checks passed
dannimad added a commit that referenced this pull request Jul 19, 2024
…ior (#21879)

## Description

In #21785, we inadvertently removed the following two function calls
from the incoming op processing code in the case of
`!modernRuntimeMessage`:

* `ensureContentsDeserialized`
* `unpackRuntimeMessage`

The second is obviously fine, we early-return on the same condition as
`modernRuntimeMessage`.

The first is _probably_ fine, but there's some ambiguity. It's possible
that there are some legacy runtime messages or system messages with an
unexpected format where we need to do this deserialization, and we must
not break those cases.

So this PR adds back that call (moving it to `ContainerRuntime.process`,
and also instruments these two functions so we can collect logs to see
if we hit certain codepaths here at scale.

---------

Co-authored-by: Daniel Madrid <105010181+dannimad@users.noreply.github.com>
dannimad added a commit that referenced this pull request Sep 13, 2024
markfields added a commit that referenced this pull request Sep 16, 2024
…g for the whole batch (#22508)

We are concerned that holding batch messages in ContainerRuntime even
while DeltaManager advances its tracked sequence numbers through the
batch could have unintended consequences. So this PR restores the old
behavior of processing each message in a batch one-by-one, rather than
holding until the whole batch arrives.

Note that there's no change in behavior here for Grouped Batches.

### How the change works

PR #21785 switched the RemoteMessageProcessor from returning ungrouped
batch ops as they arrived, to holding them and finally returning the
whole batch once the last arrived. The downstream code was also updated
to take whole batches, whereas before it would take individual messages
and use the batch metadata to detect batch start/end.

Too many other changes were made after that PR to straight revert it.
Logic was added throughout CR and PSM that looks at info about that
batch which is found on the first message in the batch. So we can
reverse the change and process one-at-a-time, but we need a way to carry
around that "batch start info" with the first message in the batch.

So we are now modeling the result that RMP yields as one of three cases:

- A full batch of messages (could be from a single-message batch or a
Grouped Batch)
- The first message of a multi-message batch
- The next message in a multi-message batch

The first two cases include the "batch start info" needed for the recent
Offline work. The third case just indicates whether it's the last
message or not.

#22501 added some of the necessary structure, introducing the type for
"batch start info" and updating the downstream code to use that instead
of reading it off the old "Inbound Batch" type. This PR now adds those
other two cases to the RMP return type and handles processing them
throughout CR and PSM.
frankmueller-msft pushed a commit that referenced this pull request Sep 16, 2024
markfields added a commit to markfields/FluidFramework that referenced this pull request Sep 26, 2024
ContainerRuntime: Process incoming batches op-by-op instead of waiting for the whole batch (microsoft#22508)

We are concerned that holding batch messages in ContainerRuntime even
while DeltaManager advances its tracked sequence numbers through the
batch could have unintended consequences. So this PR restores the old
behavior of processing each message in a batch one-by-one, rather than
holding until the whole batch arrives.

Note that there's no change in behavior here for Grouped Batches.

PR microsoft#21785 switched the RemoteMessageProcessor from returning ungrouped
batch ops as they arrived, to holding them and finally returning the
whole batch once the last arrived. The downstream code was also updated
to take whole batches, whereas before it would take individual messages
and use the batch metadata to detect batch start/end.

Too many other changes were made after that PR to straight revert it.
Logic was added throughout CR and PSM that looks at info about that
batch which is found on the first message in the batch. So we can
reverse the change and process one-at-a-time, but we need a way to carry
around that "batch start info" with the first message in the batch.

So we are now modeling the result that RMP yields as one of three cases:

- A full batch of messages (could be from a single-message batch or a
Grouped Batch)
- The first message of a multi-message batch
- The next message in a multi-message batch

The first two cases include the "batch start info" needed for the recent
Offline work. The third case just indicates whether it's the last
message or not.

"batch start info" and updating the downstream code to use that instead
of reading it off the old "Inbound Batch" type. This PR now adds those
other two cases to the RMP return type and handles processing them
throughout CR and PSM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtime Runtime related issues base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants