mirror of
https://github.com/restic/restic.git
synced 2025-08-12 11:47:43 +00:00
Centralize buffer allocation and size checking in Repository.LoadBlob
Benchmark results for internal/repository: name old time/op new time/op delta LoadTree-8 479µs ± 2% 478µs ± 1% ~ (p=0.780 n=10+9) LoadBlob-8 11.6ms ± 2% 11.6ms ± 1% ~ (p=0.631 n=10+10) LoadAndDecrypt-8 13.2ms ± 2% 13.3ms ± 3% ~ (p=0.631 n=10+10) name old alloc/op new alloc/op delta LoadTree-8 41.2kB ± 0% 41.2kB ± 0% ~ (all equal) LoadBlob-8 2.28kB ± 0% 2.28kB ± 0% ~ (all equal) LoadAndDecrypt-8 2.10MB ± 0% 2.10MB ± 0% ~ (all equal) name old allocs/op new allocs/op delta LoadTree-8 652 ± 0% 652 ± 0% ~ (all equal) LoadBlob-8 24.0 ± 0% 24.0 ± 0% ~ (all equal) LoadAndDecrypt-8 30.0 ± 0% 30.0 ± 0% ~ (all equal) name old speed new speed delta LoadBlob-8 86.2MB/s ± 2% 86.4MB/s ± 1% ~ (p=0.594 n=10+10) LoadAndDecrypt-8 75.7MB/s ± 2% 75.4MB/s ± 3% ~ (p=0.617 n=10+10)
This commit is contained in:
@@ -228,13 +228,13 @@ func TestEnsureFileContent(ctx context.Context, t testing.TB, repo restic.Reposi
|
||||
content := make([]byte, restic.CiphertextLength(len(file.Content)))
|
||||
pos := 0
|
||||
for _, id := range node.Content {
|
||||
n, err := repo.LoadBlob(ctx, restic.DataBlob, id, content[pos:])
|
||||
part, err := repo.LoadBlob(ctx, restic.DataBlob, id, content[pos:])
|
||||
if err != nil {
|
||||
t.Fatalf("error loading blob %v: %v", id.Str(), err)
|
||||
return
|
||||
}
|
||||
|
||||
pos += n
|
||||
pos += len(part)
|
||||
}
|
||||
|
||||
content = content[:pos]
|
||||
|
Reference in New Issue
Block a user