mirror of
https://github.com/restic/restic.git
synced 2026-11-25 07:16:54 +00:00
Optimize chunker
Skip MinSize bytes at the beginning of each chunk. This increases
throughput about 30% percent.
Before:
$ go test -v -bench . ./chunker
=== RUN TestChunker
--- PASS: TestChunker (0.60s)
=== RUN TestChunkerReuse
--- PASS: TestChunkerReuse (2.18s)
PASS
BenchmarkChunker 10 111229642 ns/op 94.27 MB/s
--- BENCH: BenchmarkChunker
chunker_test.go:168: 6 chunks, average chunk size: 1747626 bytes
chunker_test.go:168: 6 chunks, average chunk size: 1747626 bytes
ok github.com/restic/restic/chunker 4.120s
After:
$ go test -v -bench . ./chunker
=== RUN TestChunker
--- PASS: TestChunker (0.48s)
=== RUN TestChunkerReuse
--- PASS: TestChunkerReuse (1.75s)
PASS
BenchmarkChunker 20 81468596 ns/op 128.71 MB/s
--- BENCH: BenchmarkChunker
chunker_test.go:168: 6 chunks, average chunk size: 1747626 bytes
chunker_test.go:168: 6 chunks, average chunk size: 1747626 bytes
ok github.com/restic/restic/chunker 4.061s
This commit is contained in:
1 parent
cdf3336e7a
commit
bdcdcdea7d
2 files changed
+29
-3
No files matched your search
@@ -43,7 +43,7 @@ var chunks1 = []chunk{
|
||||
chunk{800374, 0x000968473f900000},
|
||||
chunk{2453512, 0x001e197c92600000},
|
||||
chunk{2651975, 0x000ae6c868000000},
|
||||
chunk{237392, 0x00184c5825e18636},
|
||||
chunk{237392, 0x0000000000000001},
|
||||
}
|
||||
|
||||
// test if nullbytes are correctly split, even if length is a multiple of MinSize.
|
||||
@@ -79,8 +79,8 @@ func test_with_data(t *testing.T, chnker *chunker.Chunker, chunks []chunk) {
|
||||
}
|
||||
|
||||
if c.Cut != chunk.CutFP {
|
||||
t.Fatalf("Cut fingerprint for chunk %d does not match: expected %016x, got %016x",
|
||||
i, chunk.CutFP, c.Cut)
|
||||
t.Fatalf("Cut fingerprint for chunk %d/%d does not match: expected %016x, got %016x",
|
||||
i, len(chunks)-1, chunk.CutFP, c.Cut)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user