From 4b51fbf48c18f36f82f39632d43865e631e900e3 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 24 May 2021 15:12:48 -0700 Subject: [PATCH] internal/deephash: increase scratch space size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e66d4e4c8131f89e85f372f6f41ff9580fedf140 added AppendTo methods to some key types. Their marshaled form is longer than 64 bytes. name old time/op new time/op delta Hash-8 15.5µs ± 1% 14.8µs ± 1% -4.17% (p=0.000 n=9+9) name old alloc/op new alloc/op delta Hash-8 1.18kB ± 0% 0.47kB ± 0% -59.87% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Hash-8 12.0 ± 0% 6.0 ± 0% -50.00% (p=0.000 n=10+10) This is still a bit worse than explicitly handling the types, but much nicer. Signed-off-by: Josh Bleecher Snyder --- internal/deephash/deephash.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/deephash/deephash.go b/internal/deephash/deephash.go index c360b5b78..d6f1fa068 100644 --- a/internal/deephash/deephash.go +++ b/internal/deephash/deephash.go @@ -23,7 +23,7 @@ import ( func calcHash(v interface{}) string { h := sha256.New() b := bufio.NewWriterSize(h, h.BlockSize()) - scratch := make([]byte, 0, 64) + scratch := make([]byte, 0, 128) printTo(b, v, scratch) b.Flush() scratch = h.Sum(scratch[:0])