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

Add stellar/go-xdr#16 (reduction on XDR encoding/decoding allocations) #4042

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Nov 2, 2021

This PR incorporates stellar/go-xdr#16 in Horizon.

The benchmarks (copied from stellar/xdrgen#65 but using a larger transaction) show a big improvement in the allocations made by the encoder/decoder.

Before:

goos: darwin
goarch: amd64
pkg: github.com/stellar/go/benchmarks
cpu: Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
BenchmarkXDRUnmarshal
BenchmarkXDRUnmarshal-8              100             18301 ns/op            5968 B/op        232 allocs/op
BenchmarkGXDRUnmarshal
BenchmarkGXDRUnmarshal-8             100             58419 ns/op           86738 B/op        278 allocs/op
BenchmarkXDRMarshal
BenchmarkXDRMarshal-8                100             13599 ns/op            5248 B/op        194 allocs/op
BenchmarkGXDRMarshal
BenchmarkGXDRMarshal-8               100              8561 ns/op            2152 B/op        157 allocs/op
PASS

After:

goos: darwin
goarch: amd64
pkg: github.com/stellar/go/benchmarks
cpu: Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
BenchmarkXDRUnmarshal
BenchmarkXDRUnmarshal-8              100             18851 ns/op            5576 B/op        186 allocs/op
BenchmarkGXDRUnmarshal
BenchmarkGXDRUnmarshal-8             100             51694 ns/op           86736 B/op        278 allocs/op
BenchmarkXDRMarshal
BenchmarkXDRMarshal-8                100             11203 ns/op            5128 B/op        156 allocs/op
BenchmarkGXDRMarshal
BenchmarkGXDRMarshal-8               100              8539 ns/op            2152 B/op        157 allocs/op
PASS

Note how the allocations go down:

  • from 232 to 186 (~20% reduction) for the decoder
  • from 194 to 156 (also ~20% reduction) for the encoder

This should relieve a lot of pressure in the garbage collector ( #4022 shows how allocations/garbage collection constitute a big part of Horizon's runtime)

@2opremio 2opremio force-pushed the xdr-experiments branch 5 times, most recently from 3c61f4c to 6cde1b2 Compare November 2, 2021 22:53
@2opremio 2opremio changed the title Test PR stellar/go-xdr#16 (reduction on XDR encoding/decoding allocations) Add stellar/go-xdr#16 (reduction on XDR encoding/decoding allocations) Nov 3, 2021
@2opremio 2opremio requested review from a team and leighmcculloch November 3, 2021 14:51
@2opremio 2opremio merged commit 89aa538 into stellar:master Nov 3, 2021
@2opremio 2opremio deleted the xdr-experiments branch November 3, 2021 16:21
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