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

Move drivers to streaming API for op retrieval #5703

Merged
merged 13 commits into from
Apr 8, 2021

Conversation

vladsud
Copy link
Contributor

@vladsud vladsud commented Apr 1, 2021

Hide the logic on how driver fetches ops behind streaming API.

That ensures that driver controls such aspects as

  • how ops are retrieved - in batches, or though http streaming
  • If batches are used, driver controls batch sizes and any concurrency.

As part of redesign, start introducing AbortSignal on all of our network APIs.
This allows caller to cancel complex operations. In future that would likely need to change as well to include more scenarios (including progress reporting, prioritization, etc.).

Also exposing cachedOnly flag on request for loader to have ability (future PRs) to request cached ops (cached in snapshot and cached on local machine) to be able to rehydrate container to more recent state without waiting for network call to come back. This will ensure we could address gaps in user experience.

Making [from, to) arguments to be inclusive on left side and exclusive on right side - much easier to think and do math (things like calculate length, next batch, etc.)

Expose overrides in ODSP driver, such that fetch tool can continue to be more aggressive (currently - batches of 20K in size and 4 concurrent requests).

Areas of most feedback I'd love to get - naming :)

  • IStream
  • readMessages() (more unique name, easier to find)
  • emptyMessageStream
  • streamFromMessages

Unrelated (sort of) changes:

  1. Address an issue in tests where driver & loader versions were mismatched. For now, they are one and the same. In future, this should be controlled through compat configs, not individual tests decided what version to use
  2. Catch up logic that our tests were using does not really work (or works by chance) due to r11s driver not supporting checkpoint sequence numbers. Make wait logic more inclusive by relying on own join op as a barrier.

@github-actions github-actions bot requested a review from anthony-murphy April 2, 2021 21:36
@curtisman
Copy link
Member

 * Retrieves all the delta operations within the inclusive sequence number range

Update comment, and include description per param


Refers to: packages/loader/driver-definitions/src/storage.ts:47 in 2f1834d. [](commit_id = 2f1834d, deletion_comment = False)

to: number | undefined,
abortSignal?: AbortSignal,
cachedOnly?: boolean,
): IStream<ISequencedDocumentMessage[]>;
Copy link
Member

Choose a reason for hiding this comment

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

Should be make this an "async iterator" since they are so similar already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it. Maybe. I have a feeling that it will be useful to be able to query it for more things. Like, have progress reporting (i.e. how many ops are still there, if that can be answered). Maybe we can have it both?
I do not have strong opinion here, happy to convert to async iterator.

The part that worries me is red X next to Safari on iOS:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator
Can't find equivalent, but I had to back out code earlier due to usage of async generators due to compat concerns, so I'm a bit hesitant to jump here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done manual test on iOS and async iterator is working fine for me, being on latest iOS.
That said, https://caniuse.com/?search=async%20iterator also is in red. So I'm not sure.
I'm thinking of leaving it as is for now (though ask around), until it becomes green across the board (yes, future changes would require back compat, but it's not such a big deal imho). Let me know what you think

@curtisman
Copy link
Member

while (signal?.aborted !== true) {

Should we throw an error if it is aborted?


Refers to: packages/loader/driver-utils/src/parallelRequests.ts:362 in 2f1834d. [](commit_id = 2f1834d, deletion_comment = False)

vladsud added 2 commits April 5, 2021 20:12
…to FetchOpsDriver

# Conflicts:
#	packages/drivers/odsp-driver/src/contracts.ts
#	packages/drivers/odsp-driver/src/odspDeltaStorageService.ts
#	packages/drivers/odsp-driver/src/odspDocumentService.ts
@vladsud
Copy link
Contributor Author

vladsud commented Apr 6, 2021

Ping. I'd love to move forward with it.

@@ -24,7 +24,7 @@ import winston from "winston";
import { IAlfredTenant } from "@fluidframework/server-services-client";
import { Constants } from "../../../utils";

export async function getDeltas(
async function getDeltas(
Copy link
Contributor

Choose a reason for hiding this comment

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

why the server changes?

Copy link
Contributor

@anthony-murphy anthony-murphy left a comment

Choose a reason for hiding this comment

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

looks good. we'll just need to pay attention to rollout, as this breaks driver/loader contracts which could cause problems with dynamic drivers once that lands

vladsud added 3 commits April 7, 2021 19:04
…to FetchOpsDriver

# Conflicts:
#	packages/test/test-drivers/src/odspDriverApi.ts
#	packages/test/test-end-to-end-tests/src/test/contextReload.spec.ts
@msfluid-bot
Copy link
Collaborator

@fluidframework/base-host: -4.59 KB
Metric NameBaseline SizeCompare SizeSize Diff
main.js 178.76 KB 174.17 KB -4.59 KB
Total Size 178.76 KB 174.17 KB -4.59 KB
@fluid-example/bundle-size-tests: +5.24 KB
Metric NameBaseline SizeCompare SizeSize Diff
container.js 201.78 KB 201.78 KB No change
map.js 49.11 KB 49.11 KB No change
matrix.js 143.42 KB 143.42 KB No change
odspDriver.js 203.23 KB 208.47 KB +5.24 KB
sharedString.js 158.14 KB 158.14 KB No change
Total Size 755.69 KB 760.93 KB +5.24 KB

Baseline commit: 6555aa8

Generated by 🚫 dangerJS against db0e0dd

@vladsud vladsud merged commit d4f68c8 into microsoft:main Apr 8, 2021
@vladsud vladsud deleted the FetchOpsDriver branch April 8, 2021 06:15
@github-actions github-actions bot requested a review from anthony-murphy April 8, 2021 07:54
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.

4 participants