-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use custom encoding for jmessage wrappers.
For the parts of the JSON-RPC wrapper that are fixed, it is noticeably faster to explicitly encode them rather than routing through json.Marshal. We still use json.Marshal to handle parameters. name old time/op new time/op delta EncodeMessage/1-12 1.32µs ± 0% 0.28µs ± 0% -79.12% EncodeMessage/2-12 1.25µs ± 0% 0.21µs ± 0% -83.03% EncodeMessage/3-12 1.25µs ± 0% 0.13µs ± 0% -89.47% EncodeMessage/4-12 521ns ± 0% 415ns ± 0% -20.46% EncodeMessage/batch-12 7.93µs ± 0% 1.35µs ± 0% -82.94% This helps the round-trip benchmarks as well: BENCHMARK BEFORE AFTER SPEEDUP (%) BenchmarkRoundTrip/C01-CTX-B-12 20270 16556 18.3 BenchmarkRoundTrip/C01-CTX+B-12 20569 16638 19.1 BenchmarkRoundTrip/C04-CTX-B-12 20251 16618 17.9 BenchmarkRoundTrip/C04-CTX+B-12 20262 16504 18.5 BenchmarkRoundTrip/C12-CTX-B-12 20188 16561 18.0 BenchmarkRoundTrip/C12-CTX+B-12 20254 16661 17.7 BenchmarkRoundTrip/C01+CTX-B-12 22401 18697 16.5 BenchmarkRoundTrip/C01+CTX+B-12 22337 18977 15.0 BenchmarkRoundTrip/C04+CTX-B-12 22248 18769 15.6 BenchmarkRoundTrip/C04+CTX+B-12 22216 18881 15.0 BenchmarkRoundTrip/C12+CTX-B-12 22447 18999 15.4 BenchmarkRoundTrip/C12+CTX+B-12 22191 19111 13.9 Related changes: - Add JSON encoding benchmarks under the tag "oldbench". - Split JSON handling into a separate file. New file: json.go
- Loading branch information
1 parent
334382b
commit 6c2c662
Showing
4 changed files
with
352 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.