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

Refactor forest's applyDelta to return a visitor #17163

Merged
merged 8 commits into from
Sep 6, 2023

Conversation

jenn-le
Copy link
Contributor

@jenn-le jenn-le commented Sep 1, 2023

Description

Changes applyDelta to acquireVisitor so that multiple visitors can be used together.

@jenn-le jenn-le requested a review from a team as a code owner September 1, 2023 22:40
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree public api change Changes to a public API base: main PRs targeted against main branch labels Sep 1, 2023
@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Sep 1, 2023

@fluid-example/bundle-size-tests: +2.26 KB
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 438.56 KB 438.56 KB No change
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 237.31 KB 237.31 KB No change
loader.js 148.66 KB 148.66 KB No change
map.js 46.54 KB 46.54 KB No change
matrix.js 139.35 KB 139.35 KB No change
odspDriver.js 89.09 KB 89.09 KB No change
odspPrefetchSnapshot.js 41.58 KB 41.58 KB No change
sharedString.js 155.59 KB 155.59 KB No change
sharedTree2.js 240.51 KB 242.77 KB +2.26 KB
Total Size 1.64 MB 1.65 MB +2.26 KB

Baseline commit: 0bde699

Generated by 🚫 dangerJS against e41152b

"Must release existing visitor before acquiring another",
);
this.events.emit("beforeChange");

this.invalidateDependents();
assert(
Copy link
Contributor

Choose a reason for hiding this comment

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

previously this used to be enough to assert that no cursors (other than the one used foe the update) exist during delta application. With this change, this check (and likely a similar one in chunked forest) is no longer enough.

There are two approaches we can take to close this safety gap:

  1. Add assert(this.forest.activeVisitor === undefined) into Cursor.setToAboveDetachedSequences (this will ban any use of cursors while you have a visitor)
  2. OR: in the visitor implementation, before it makes each change, do this.invalidateDependents(); this.currentCursors.size === 1, and remove those checks from here (this will allow using cursors inbetween edits, for example inspecting the editiable tree on the delta events.)

Equivalent changes will be needed for chunked forest.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you go with the second option, you might want to move before and after change into each individual edit as well, or at least update the docs on those events to clarify when they fire.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch! Thanks for noticing that. I'm guessing we want option #2 given where we're headed.

@yann-achard-MS yann-achard-MS merged commit 26a162f into microsoft:main Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: tree area: dds Issues related to distributed data structures base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants