From d45df614fba0e4b6b52ffdf83e19ca227e53838b Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 21 Mar 2022 16:59:33 +0300 Subject: [PATCH] [#1262] metabase: Optimize `decodeList` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent additional allocation during `append` in `Put`. ``` name old alloc/op new alloc/op delta Put/parallel-8 131kB ± 1% 126kB ± 4% -3.87% (p=0.005 n=8+8) Put/sequential-8 172kB ± 1% 171kB ± 1% -0.73% (p=0.028 n=10+9) ``` Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/metabase/put.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index b898e872..e23760a2 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -379,7 +379,7 @@ func decodeList(data []byte) (lst [][]byte, err error) { } r := io.NewBinReaderFromBuf(data) l := r.ReadVarUint() - lst = make([][]byte, l) + lst = make([][]byte, l, l+1) for i := range lst { lst[i] = r.ReadVarBytes() }