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

Add SyncV2 Causal Negotiation #5570

Merged
merged 8 commits into from
Feb 5, 2025
Merged

Add SyncV2 Causal Negotiation #5570

merged 8 commits into from
Feb 5, 2025

Conversation

ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Feb 5, 2025

Overview

UCM will now use the new causal-dependencies endpoint to determine which dependencies of a new root it already has, then will tell Share to skip certain dependencies in its stream.

This massively speeds up incremental pulls on a given branch.

Implementation notes

Before initiating a download, ask Share to enumerate relevant dependencies (currently the causal spine and all contained library causal hashes). Then pass the list of dependencies we've already got along to the download endpoint.

Note: this now clears the temp_entity tables before starting a pull.v2, we still have code to check temp entities on every insert, so clearing the tables speeds that up. There's not much reason to keep large amounts of code sitting around in there when the user isn't actively trying to pull.v1 something.

Interesting/controversial decisions

Nope

Test coverage

I've done a bunch of testing on staging, but would be good to dogfood it a bit with the Unison team or early adopters.

Loose ends

  • Track the remote causal for branches we've pulled so we can just use that as a known causal.

@ChrisPenner ChrisPenner force-pushed the syncv2/causal-negotiation branch from 5a74104 to 40af0b1 Compare February 5, 2025 17:58
Base automatically changed from syncv2/experiments to trunk February 5, 2025 18:24
@@ -116,6 +117,9 @@ syncFromFile ::
Cli (Either (SyncError SyncV2.PullError) CausalHash)
syncFromFile shouldValidate syncFilePath = do
Cli.Env {codebase} <- ask
-- Every insert into SQLite checks the temp entity tables, but syncv2 doesn't actually use them, so it's faster
-- if we clear them out before starting a sync.
Cli.runTransaction Q.clearTempEntityTables
Copy link
Contributor

Choose a reason for hiding this comment

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

The temp entity table should be empty except if a past sync failed and was never completed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup; but it's also never otherwise cleared, so if you accidentally clone @unison/base/main instead of lib.install @unison/base or something like that it'll leave junk in there basically forever.

@ChrisPenner ChrisPenner merged commit c4149a9 into trunk Feb 5, 2025
32 checks passed
@ChrisPenner ChrisPenner deleted the syncv2/causal-negotiation branch February 5, 2025 19:57
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.

2 participants