This repository has been archived by the owner on Sep 6, 2018. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
switch to use gogoprotobuf generated codes.
Gogoprobuf will generate helper codes that do not use reflection.
Performance improvement about 50% for the switching.
Another 100%+ improvement for refactoring.
Before using gogoprotobuf
BenchmarkAppendEntriesRequestEncoding 1000 1806812 ns/op 74.17 MB/s
BenchmarkAppendEntriesRequestDecoding 1000 2217673 ns/op 60.43 MB/s
BenchmarkAppendEntriesResponseEncoding 1000000 1424 ns/op 5.62 MB/s
BenchmarkAppendEntriesResponseDecoding 1000000 3434 ns/op 2.33 MB/s
After using gogoprotobuf
BenchmarkAppendEntriesRequestEncoding 2000 1084766 ns/op 123.54 MB/s
BenchmarkAppendEntriesRequestDecoding 1000 1715724 ns/op 78.11 MB/s
BenchmarkAppendEntriesResponseEncoding 5000000 636 ns/op 12.57 MB/s
BenchmarkAppendEntriesResponseDecoding 1000000 2469 ns/op 3.24 MB/s
After refactoring (stop copying around)
BenchmarkAppendEntriesRequestEncoding 5000 367500 ns/op 364.67 MB/s
BenchmarkAppendEntriesRequestDecoding 2000 1448770 ns/op 92.50 MB/s
BenchmarkAppendEntriesResponseEncoding 5000000 642 ns/op 12.46 MB/s
BenchmarkAppendEntriesResponseDecoding 1000000 2225 ns/op 3.59 MB/s
There are still some improving space. I am working on this.