Skip to content

Conversation

@meling
Copy link
Member

@meling meling commented Apr 21, 2022

This will remove the translation layer to avoid allocations and improve performance.

meling and others added 30 commits April 21, 2022 11:20
This adds an interface for message types: Proposal, Block and AggQC.

Adds a constructor for ProposeMsg.

Adds benchmark for translation layer allocation, interface-based
construction, and interface field access, direct field access
and method field access.
This adds an interface for message types: Proposal, Block and AggQC.

Adds a constructor for ProposeMsg.

Adds benchmark for translation layer allocation, interface-based
construction, and interface field access, direct field access
and method field access.
This adds a few alternative Block implementations and corresponding
benchmarks to better understand their performance. The conclusion
so far is that doing pure protobuf allocation is almost 50% faster,
but then we can't cache the hash, unless we add the hash field to
the proto message.

The existing ToBytes implmentation is slighly faster than using
protobuf's default Marshal function, but the latter is allocating
less...

```sh
% go test -v -bench . -benchtime 5s -run x -bench Bench -count 3
goos: darwin
goarch: amd64
pkg: github.com/relab/hotstuff/msg
cpu: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
BenchmarkNewBlock
BenchmarkNewBlock-24         	 5455846	      1098 ns/op	     408 B/op	       5 allocs/op
BenchmarkNewBlock-24         	 5455090	      1095 ns/op	     408 B/op	       5 allocs/op
BenchmarkNewBlock-24         	 5448262	      1093 ns/op	     408 B/op	       5 allocs/op
BenchmarkNewBlockX
BenchmarkNewBlockX-24        	38660383	       151.5 ns/op	     152 B/op	       3 allocs/op
BenchmarkNewBlockX-24        	39646353	       151.5 ns/op	     152 B/op	       3 allocs/op
BenchmarkNewBlockX-24        	39666562	       152.5 ns/op	     152 B/op	       3 allocs/op
BenchmarkNewBlockY
BenchmarkNewBlockY-24        	 6527548	       919.0 ns/op	     264 B/op	       5 allocs/op
BenchmarkNewBlockY-24        	 6519303	       923.6 ns/op	     264 B/op	       5 allocs/op
BenchmarkNewBlockY-24        	 6444274	       926.5 ns/op	     264 B/op	       5 allocs/op
BenchmarkNewBlockProto
BenchmarkNewBlockProto-24    	56463015	       104.4 ns/op	     120 B/op	       2 allocs/op
BenchmarkNewBlockProto-24    	56531526	       104.8 ns/op	     120 B/op	       2 allocs/op
BenchmarkNewBlockProto-24    	56849295	       105.7 ns/op	     120 B/op	       2 allocs/op
BenchmarkToBytes
BenchmarkToBytes-24          	27228734	       219.6 ns/op	     248 B/op	       4 allocs/op
BenchmarkToBytes-24          	27296708	       221.3 ns/op	     248 B/op	       4 allocs/op
BenchmarkToBytes-24          	27144760	       221.1 ns/op	     248 B/op	       4 allocs/op
BenchmarkToBytesX
BenchmarkToBytesX-24         	22433918	       261.8 ns/op	      64 B/op	       1 allocs/op
BenchmarkToBytesX-24         	22655881	       260.7 ns/op	      64 B/op	       1 allocs/op
BenchmarkToBytesX-24         	22796553	       260.8 ns/op	      64 B/op	       1 allocs/op
BenchmarkToBytesY
BenchmarkToBytesY-24         	22889803	       260.9 ns/op	      64 B/op	       1 allocs/op
BenchmarkToBytesY-24         	22500680	       260.6 ns/op	      64 B/op	       1 allocs/op
BenchmarkToBytesY-24         	22840678	       260.2 ns/op	      64 B/op	       1 allocs/op
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants