diff --git a/README.md b/README.md index d1c000e..63482fb 100644 --- a/README.md +++ b/README.md @@ -23,30 +23,28 @@ go get github.com/klauspost/reedsolomon # Usage # Performance -The library is not heavily optimized at the moment. In the future it is very likely - -Performance depends mainly on the number of data and parity shards. In rough terms, doubling the number of data and parity shards will double the encoding time. +Performance depends mainly on the number of parity shards. In rough terms, doubling the number of parity shards will double the encoding time. Here are the throughput numbers with some different selections of data and parity shards. For reference each shard is 1MB random data, and 2 CPU cores are used for encoding. -| Data | Parity | MB/s | Speed | -|------|--------|--------|---------| -| 5 | 2 | 209.87 | 100.00% | -| 10 | 2 | 151.96 | 72.41% | -| 10 | 4 | 106.72 | 50.85% | -| 50 | 20 | 13.59 | 6.48% | +| Data | Parity | MB/s | Parity | Speed | +|------|--------|--------|--------|---------| +| 5 | 2 | 427,62 | 40% | 100,00% | +| 10 | 2 | 525,84 | 20% | 122,97% | +| 10 | 4 | 265,85 | 40% | 62,17% | +| 50 | 20 | 52,98 | 40% | 12,39% | If `runtime.GOMAXPROCS()` is set to a value higher than 1, the encoder will use multiple goroutines to perform the calculations in `Verify`, `Encode` and `Reconstruct`. Example of performance scaling on Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz - 4 physical cores, 8 logical cores. The example uses 10 blocks with 16MB data each and 4 parity blocks. -| Threads | MB/s | Speed | -|---------|-------|-------| -| 1 | 24.34 | 100% | -| 2 | 48.47 | 199% | -| 4 | 78.28 | 322% | -| 8 | 97.88 | 402% | +| Threads | MB/s | Speed | +|---------|--------|---------| +| 1 | 156,49 | 100,00% | +| 2 | 287,86 | 199,00% | +| 4 | 491,83 | 322,00% | +| 8 | 575,32 | 402,00% | # License diff --git a/reedsolomon_test.go b/reedsolomon_test.go index dc035ad..3f0612d 100644 --- a/reedsolomon_test.go +++ b/reedsolomon_test.go @@ -232,6 +232,26 @@ func BenchmarkEncode10x4x16M(b *testing.B) { benchmarkEncode(b, 10, 4, 16*1024*1024) } +// Benchmark 1 data shards and 2 parity shards with 1MB each. +func BenchmarkEncode5x2x1M(b *testing.B) { + benchmarkEncode(b, 5, 2, 1024*1024) +} + +// Benchmark 1 data shards and 2 parity shards with 1MB each. +func BenchmarkEncode10x2x1M(b *testing.B) { + benchmarkEncode(b, 10, 2, 1024*1024) +} + +// Benchmark 1 data shards and 2 parity shards with 1MB each. +func BenchmarkEncode10x4x1M(b *testing.B) { + benchmarkEncode(b, 10, 4, 1024*1024) +} + +// Benchmark 1 data shards and 2 parity shards with 1MB each. +func BenchmarkEncode50x20x1M(b *testing.B) { + benchmarkEncode(b, 50, 20, 1024*1024) +} + func benchmarkVerify(b *testing.B, dataShards, parityShards, shardSize int) { r, err := New(dataShards, parityShards) if err != nil {