From 9576e10d0415db815724629b6a5bdfbf0a406565 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 30 Nov 2021 19:26:20 +0300 Subject: [PATCH] storage: use map size hints to optimize subsequent persist() We're likely to have something comparable to the current changeset in the subsequent one. If it's bigger, no big deal, it'll be reallocated, if it's smaller, no big deal, the next one will be preallocated smaller. --- pkg/core/storage/memcached_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/storage/memcached_store.go b/pkg/core/storage/memcached_store.go index 065c7303f..d9a6dcbbc 100644 --- a/pkg/core/storage/memcached_store.go +++ b/pkg/core/storage/memcached_store.go @@ -252,8 +252,8 @@ func (s *MemCachedStore) persist(isSync bool) (int, error) { // unprotected while writes are handled by s proper. var tempstore = &MemCachedStore{MemoryStore: MemoryStore{mem: s.mem, del: s.del}, ps: s.ps} s.ps = tempstore - s.mem = make(map[string][]byte) - s.del = make(map[string]bool) + s.mem = make(map[string][]byte, len(s.mem)) + s.del = make(map[string]bool, len(s.del)) if !isSync { s.mut.Unlock() }