mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
905d769f6f
Earlier wire.Uint.save() could make up to 10 Write() calls depending on how large the Uint being marshaled was. Write() is an interface method call, so this avoids the dynamic dispatch overhead. Furthermore, compressio's Write implementations themselves do a bunch of fixed work per call and invoke more interface functions. Increased the scratch buffer in the wire.Writer to accommodate 10 bytes. The wire.Uint can be marshaled into at most 10 bytes. Before: goos: linux goarch: amd64 pkg: pkg/state/wire/wire cpu: AMD EPYC 7B12 BenchmarkUintSave BenchmarkUintSave-24 37557860 31.13 ns/op 0 B/op 0 allocs/op After: goos: linux goarch: amd64 pkg: pkg/state/wire/wire cpu: AMD EPYC 7B12 BenchmarkUintSave BenchmarkUintSave-24 129611625 9.274 ns/op 0 B/op 0 allocs/op PiperOrigin-RevId: 672679703