On Wednesday, January 23, 2013 7:19:02 PM UTC+1, John Graham-Cumming wrote:
I tested that implementation of Blake2 using the same tests as I used for native Go and OpenSSL functions. Looking just at native Go my test of hashing 4.4GB of data came in at MD5 404 MB/s, SHA1 123 MB/s, Blake2 201 MB/s. So, it was about half the speed of MD5. I will spend some time looking at the optimized C version of Blake2 with a Go wrapper for comparison.
Very strange that there's 2x difference between MD5 and BLAKE2. Did you test BLAKE2b (it's faster on 64-bit CPUs)? Here are benchmarks on my Core 2 Duo laptop:
PASS
BenchmarkWrite1K 500000 4950 ns/op 206.83 MB/s
BenchmarkWrite8K 50000 38870 ns/op 210.75 MB/s
BenchmarkHash64 1000000 1520 ns/op 42.10 MB/s
BenchmarkHash128 1000000 1435 ns/op 89.15 MB/s
BenchmarkHash1K 500000 5955 ns/op 171.93 MB/s
~/sources/go/src/pkg/crypto/md5 $ go test -test.bench=.
PASS
BenchmarkHash8Bytes 5000000 740 ns/op 10.81 MB/s
BenchmarkHash1K 500000 4349 ns/op 235.45 MB/s
BenchmarkHash8K 100000 29707 ns/op 275.75 MB/s
BenchmarkHash8BytesUnaligned 5000000 740 ns/op 10.80 MB/s
BenchmarkHash1KUnaligned 500000 4734 ns/op 216.26 MB/s
BenchmarkHash8KUnaligned 50000 31874 ns/op 257.01 MB/s
ok crypto/md5 18.776s
Note that MD5 uses unsafe package, while BLAKE2b doesn't.
When I modified it to use unsafe, it was as fast as MD5.