Skip to content
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

Create xdr.EncodingBuffer, which reduces buffer allocations #4056

Merged
merged 7 commits into from
Nov 10, 2021

Commits on Nov 10, 2021

  1. Create xdr.Encoder, which reduces buffer allocations

    It reduces a few a allocations but it seems to reduce CPU consumption by ~7%
    
    ```
    goos: darwin
    goarch: amd64
    pkg: github.com/stellar/go/benchmarks
    cpu: Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    BenchmarkXDRMarshal
    BenchmarkXDRMarshal-8                          	  102685	     11346 ns/op	    5128 B/op	     156 allocs/op
    BenchmarkXDRMarshalWithEncoder
    BenchmarkXDRMarshalWithEncoder-8               	  106569	     10636 ns/op	    3920 B/op	     150 allocs/op
    BenchmarkXDRMarshalHex
    BenchmarkXDRMarshalHex-8                       	   94836	     12340 ns/op	    6920 B/op	     158 allocs/op
    BenchmarkXDRMarshalHexWithEncoder
    BenchmarkXDRMarshalHexWithEncoder-8            	  104115	     11393 ns/op	    4816 B/op	     151 allocs/op
    BenchmarkXDRUnsafeMarshalHexWithEncoder
    BenchmarkXDRUnsafeMarshalHexWithEncoder-8      	  104821	     11024 ns/op	    3920 B/op	     150 allocs/op
    BenchmarkXDRMarshalBase64
    BenchmarkXDRMarshalBase64-8                    	   96364	     12162 ns/op	    6280 B/op	     158 allocs/op
    BenchmarkXDRMarshalBase64WithEncoder
    BenchmarkXDRMarshalBase64WithEncoder-8         	  104962	     11236 ns/op	    4496 B/op	     151 allocs/op
    BenchmarkXDRUnsafeMarshalBase64WithEncoder
    BenchmarkXDRUnsafeMarshalBase64WithEncoder-8   	  102901	     11042 ns/op	    3920 B/op	     150 allocs/op
    ```
    2opremio committed Nov 10, 2021
    Configuration menu
    Copy the full SHA
    e95f4c3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e106b43 View commit details
    Browse the repository at this point in the history
  3. Use EncodeTo functions

    2opremio committed Nov 10, 2021
    Configuration menu
    Copy the full SHA
    4155b9c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    374cfe9 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    bbec4ec View commit details
    Browse the repository at this point in the history
  6. Address review feedback

    2opremio committed Nov 10, 2021
    Configuration menu
    Copy the full SHA
    b434d7d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    8494f90 View commit details
    Browse the repository at this point in the history