hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.25k stars 236 forks source link

Improve yamux benches #70

Closed tarndt closed 6 years ago

tarndt commented 6 years ago

Refactor benches and add finer grained bench cases:

  1. Minor cleanups (inconsistent var names between similar code, etc)
  2. Report allocs and throughput
  3. Run benches with fixed parameters with a wider array of inputs to better show scaling effects
  4. Implement parallel version of primary bench test

Example output:

BenchmarkPing-16                          200000          7719 ns/op         458 B/op          8 allocs/op
BenchmarkAccept-16                        100000         21225 ns/op        1412 B/op         22 allocs/op
BenchmarkSendRecv32-16                    200000          6279 ns/op       5.10 MB/s          80 B/op          2 allocs/op
BenchmarkSendRecv64-16                    200000          6380 ns/op      10.03 MB/s          80 B/op          2 allocs/op
BenchmarkSendRecv128-16                   200000          6192 ns/op      20.67 MB/s          80 B/op          2 allocs/op
BenchmarkSendRecv256-16                   200000          6384 ns/op      40.10 MB/s          80 B/op          2 allocs/op
BenchmarkSendRecv512-16                   200000          6285 ns/op      81.46 MB/s          80 B/op          2 allocs/op
BenchmarkSendRecv1024-16                  200000          6519 ns/op     157.06 MB/s          80 B/op          2 allocs/op
BenchmarkSendRecv2048-16                  200000          6598 ns/op     310.36 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecv4096-16                  200000          7000 ns/op     585.14 MB/s          83 B/op          2 allocs/op
BenchmarkSendRecvLarge-16                     10     147034782 ns/op    3651.32 MB/s      359793 B/op       6946 allocs/op
BenchmarkSendRecvParallel32-16            200000          6215 ns/op       5.15 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel64-16            200000          6759 ns/op       9.47 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel128-16           200000          6632 ns/op      19.30 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel256-16           200000          6804 ns/op      37.62 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel512-16           200000          6818 ns/op      75.09 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel1024-16          200000          6852 ns/op     149.44 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel2048-16          200000          7732 ns/op     264.85 MB/s          81 B/op          2 allocs/op
BenchmarkSendRecvParallel4096-16          200000          7449 ns/op     549.84 MB/s          82 B/op          2 allocs/op

New code passes with --race. (there is a race condition in existing tests)

tarndt commented 6 years ago

@armon I have some follow up work based on this PR. Could you be so kind as to review? Thanks!

armon commented 6 years ago

@tarndt Looks good, thanks!

tarndt commented 6 years ago

Thank you!