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

Diff speedup #2598

Merged
merged 3 commits into from
Sep 13, 2020
Merged

Diff speedup #2598

merged 3 commits into from
Sep 13, 2020

Conversation

MichaelEischer
Copy link
Member

@MichaelEischer MichaelEischer commented Feb 22, 2020

What is the purpose of this change? What does it change?

Optimize diff calculation for shared subtrees.

When the diff calculation compares two trees with identical id then no
differences between them can ever show up. Optimize for that case by
simply traversing the tree only once to collect all referenced blobs for
a proper calculation of added and removed blobs.

Just skipping the common subtrees is not possible as this would skew the
results if the added or removed blobs are shared with one of the
subtrees.

This change can speed-up the diff calculation by up to a factor two. I'm not sure whether that's worth a changelog entry or not.

Was the change discussed in an issue or in the forum before?

No.

Checklist

  • I have read the Contribution Guidelines
  • I have added tests for all changes in this PR
  • [ ] I have added documentation for the changes (in the manual)
  • There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • I have run gofmt on the code in all commits
  • All commit messages are formatted in the same style as the other commits in the repo
  • I'm done, this Pull Request is ready for review

@MichaelEischer MichaelEischer force-pushed the diff-speedup branch 2 times, most recently from d87a569 to 7eee19e Compare February 22, 2020 20:56
@greatroar
Copy link
Contributor

Confirmed, this gives a big speedup in a quick test on two ~120GB snapshots with nearly equal data. Master:

real	0m49,034s
user	0m56,896s
sys	0m3,197s

This PR:

real	0m27,803s
user	0m34,930s
sys	0m1,678s

When the diff calculation compares two trees with identical id then no
differences between them can ever show up. Optimize for that case by
simply traversing the tree only once to collect all referenced blobs for
a proper calculation of added and removed blobs.

Just skipping the common subtrees is not possible as this would skew the
results if the added or removed blobs are shared with one of the
subtrees.
Copy link
Member

@fd0 fd0 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@fd0 fd0 merged commit b10dce5 into restic:master Sep 13, 2020
@MichaelEischer MichaelEischer deleted the diff-speedup branch September 13, 2020 14:46
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.

3 participants