Files
Ayush Ranjan 905d769f6f Optimize wire.Uint.save() to make only 1 Write() call.
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
2024-09-09 14:45:45 -07:00
..