Skip to content

Refactor index decoding#3019

Merged
MichaelEischer merged 2 commits intorestic:masterfrom
greatroar:refactor-decodeindex
Oct 15, 2020
Merged

Refactor index decoding#3019
MichaelEischer merged 2 commits intorestic:masterfrom
greatroar:refactor-decodeindex

Conversation

@greatroar
Copy link
Copy Markdown
Contributor

What does this PR change? What problem does it solve?

There were three places in the codebase that did

decode new-style index -> check error -> decode old-style index

via a system of callbacks. I've replaced all three by a single DecodeIndex that can handle both formats, saving some 20 lines of code, two public functions in internal/repository and one public error type.

There's still some repetition in the code, but I didn't see a clean way of getting rid it. Two of the call sites pass a buffer around that would have to become an argument and a fourth return value on DecodeIndex.

New-style decoding is as fast as it was before:

name                   old time/op  new time/op  delta
DecodeIndex-8           4.19s ± 2%   4.16s ± 1%   ~     (p=0.105 n=10+10)
DecodeIndexParallel-8   4.18s ± 1%   4.17s ± 1%   ~     (p=0.360 n=10+8)

Decoding old-format indices no longer requires loading and decrypting twice, so that may be faster, but there's no benchmark for that.

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

No.

Checklist

greatroar added 2 commits October 13, 2020 20:47
Decoding old-format indices no longer requires loading and decrypting
twice.
Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

LGTM. There is a minimal change in behavior such that a index is now only reported to have the old format when it can actually be loaded as such, which is actually more accurate than before.

@MichaelEischer MichaelEischer merged commit 4ba237b into restic:master Oct 15, 2020
@greatroar greatroar deleted the refactor-decodeindex branch October 16, 2020 06:33
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