Skip to content

Reimplement LookupBlobSize without loop + allocation#2788

Closed
greatroar wants to merge 4 commits intorestic:masterfrom
greatroar:lookupblobsize
Closed

Reimplement LookupBlobSize without loop + allocation#2788
greatroar wants to merge 4 commits intorestic:masterfrom
greatroar:lookupblobsize

Conversation

@greatroar
Copy link
Copy Markdown
Contributor

@greatroar greatroar commented Jun 14, 2020

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

Repository.LookupBlobSize calls Index.LookupSize, which calls Index.Lookup. That method constructs a list of all known locations for blob in a newly allocated slice, using an implicit loop in the copy function. The slice is then ignored except for the first element.

This PR changes LookupSize to just do its own lookup and return the first hit. This should speed up restic mount. The restorer can now also use LookupBlobSize instead of its own reimplementation of the size lookup, decoupling it from crypto.

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

This should fix any performance regression caused by #2787.

Checklist

  • I have read the Contribution Guidelines
  • I have enabled maintainer edits for this PR
  • 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

@greatroar
Copy link
Copy Markdown
Contributor Author

Reviewers: please check #2789 first.

@MichaelEischer
Copy link
Copy Markdown
Member

Closing this as the change was merged as part of #2812.

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