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

Make the initial synchronization of a sharing faster #4147

Merged
merged 4 commits into from
Oct 10, 2023
Merged

Conversation

nono
Copy link
Member

@nono nono commented Oct 3, 2023

No description provided.

When a user accepts to synchronize a sharing to their Cozy, the stack
starts a replication of the io.cozy.files, and uploads the files inside
the sharing. We can make this process faster by batching calls to the
changes feed. It is particulary useful when there are lots of documents
in the io.cozy.shared database, from other sharings.
@nono nono marked this pull request as ready for review October 9, 2023 14:11
@nono nono requested a review from a team as a code owner October 9, 2023 14:11
Comment on lines +59 to +60
m := members[i]
g.Go(func() error {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to pass m as an argument to the goroutine to create a closure?

Copy link
Member Author

Choose a reason for hiding this comment

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

errgroup doesn't allow to pass arguments to the goroutine. That's why I have written for i := range members { m := members[i] instead of the shorter for _, m := range members. It forces m to have the correct range.

In the future, I hope that https://github.com/golang/go/wiki/LoopvarExperiment will make things easier.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation.

@nono nono merged commit 843f8d4 into master Oct 10, 2023
6 checks passed
@nono nono deleted the faster-sharing-init branch October 10, 2023 09: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