-
Notifications
You must be signed in to change notification settings - Fork 18k
encoding/base32: increase performance and code reuse #30376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR (HEAD: 3a9ab89) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/163598 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 1: Can you compare your benchmarks using benchstat (https://godoc.org/golang.org/x/perf/cmd/benchstat) after running the benchmarks with a count of 10 ? Also, can you check if stripNewlines inlines ? Ideally, we wouldn't want to lose performance in (*NewDecoder).Read. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Andrew Bonventre: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Sven Taute: Patch Set 3: (1 comment) I updated the benchmark comparison using benchstat with 10 runs. Thanks for the hint regarding inlining - unfortunately, stripNewlines does not get inlined. I just did some benchmarks, this degrades performance by about 4%. I am not sure whether I should duplicate the code because of this, it seems that most packages using base32 do not use NewDecoder. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Brad Fitzpatrick: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
This PR (HEAD: 0d6c6a0) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/163598 to see it. Tip: You can toggle comments from me using the |
Message from Sven Taute: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 4: (4 comments) Please update the benchmarks with the new code. Thanks. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
This PR (HEAD: 8e8bdbb) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/163598 to see it. Tip: You can toggle comments from me using the |
Message from Sven Taute: Patch Set 6: (4 comments) I addressed PS4 and updated the benchmark comparison. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 6: Run-TryBot+1 (1 comment) Over to Brad for the final decision. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Gobot Gobot: Patch Set 6: TryBots beginning. Status page: https://farmer.golang.org/try?commit=ce95c155 Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Gobot Gobot: Patch Set 6: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Brad Fitzpatrick: Patch Set 6: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 6: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Brad Fitzpatrick: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Brad Fitzpatrick: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from shankar shivanna: Patch Set 6: ok Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Brad Fitzpatrick: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Sven Taute: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
8e8bdbb
to
7b7737d
Compare
This PR (HEAD: 7b7737d) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/163598 to see it. Tip: You can toggle comments from me using the |
Message from Sven Taute: Patch Set 8: (4 comments) I changed stripNewlines so it accepts a src and dst, which might be the same backing array. It will now always perform a copy. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Agniva De Sarker: Patch Set 8: Sven, would you like to do a rebase with the latest master and update the benchmarks once more so that we have the latest numbers ? I have also added Ian who can help with review. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
7b7737d
to
f4be3cf
Compare
This PR (HEAD: f4be3cf) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/163598 to see it. Tip: You can toggle comments from me using the |
Message from Sven Taute: Patch Set 10: Commit message was updated. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Sven Taute: Patch Set 10:
Thanks for taking this up again. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Ian Lance Taylor: Patch Set 12: Patch Set 11 was rebased Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Ian Lance Taylor: Patch Set 12: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Gobot Gobot: Patch Set 12: TryBots beginning. Status page: https://farmer.golang.org/try?commit=b908ed16 Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Message from Gobot Gobot: Patch Set 12: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/163598. |
Add benchmarks for the Encode/Decode functions operating on []byte and increase decoding performance by removing the calls to strings.Map/bytes.Map and reusing the newline filtering code that is used by NewDecoder. Cut allocations in half for DecodeString. Comparison using the new benchmarks: name old time/op new time/op delta Encode 16.7µs ± 1% 17.0µs ± 2% +2.25% (p=0.000 n=9+9) EncodeToString 21.1µs ± 1% 20.9µs ± 1% -0.96% (p=0.000 n=10+10) Decode 141µs ± 1% 54µs ± 1% -61.51% (p=0.000 n=10+10) DecodeString 81.4µs ± 0% 54.7µs ± 1% -32.79% (p=0.000 n=9+10) name old speed new speed delta Encode 492MB/s ± 1% 481MB/s ± 2% -2.19% (p=0.000 n=9+9) EncodeToString 389MB/s ± 1% 392MB/s ± 1% +0.97% (p=0.000 n=10+10) Decode 93.0MB/s ± 1% 241.6MB/s ± 1% +159.82% (p=0.000 n=10+10) DecodeString 161MB/s ± 0% 240MB/s ± 1% +48.78% (p=0.000 n=9+10) Change-Id: Id53633514a9e14ecd0389d52114b2b8ca64370cb GitHub-Last-Rev: f4be3cf GitHub-Pull-Request: #30376 Reviewed-on: https://go-review.googlesource.com/c/go/+/163598 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
This PR is being closed because golang.org/cl/163598 has been merged. |
Add benchmarks for the Encode/Decode functions operating on []byte and increase decoding performance by removing the calls to strings.Map/bytes.Map and reusing the newline filtering code that is used by NewDecoder.
Cut allocations in half for DecodeString.
Comparison using the new benchmarks:
name old time/op new time/op delta
Encode 16.7µs ± 1% 17.0µs ± 2% +2.25% (p=0.000 n=9+9)
EncodeToString 21.1µs ± 1% 20.9µs ± 1% -0.96% (p=0.000 n=10+10)
Decode 141µs ± 1% 54µs ± 1% -61.51% (p=0.000 n=10+10)
DecodeString 81.4µs ± 0% 54.7µs ± 1% -32.79% (p=0.000 n=9+10)
name old speed new speed delta
Encode 492MB/s ± 1% 481MB/s ± 2% -2.19% (p=0.000 n=9+9)
EncodeToString 389MB/s ± 1% 392MB/s ± 1% +0.97% (p=0.000 n=10+10)
Decode 93.0MB/s ± 1% 241.6MB/s ± 1% +159.82% (p=0.000 n=10+10)
DecodeString 161MB/s ± 0% 240MB/s ± 1% +48.78% (p=0.000 n=9+10)