From 94fff219abb5037ebd1d585cc52fd6b35562625c Mon Sep 17 00:00:00 2001 From: fengyuceNv Date: Tue, 13 Nov 2018 20:19:05 +0800 Subject: [PATCH] improve remote storage enqueue performance (#4772) Signed-off-by: fyc --- storage/remote/queue_manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/remote/queue_manager.go b/storage/remote/queue_manager.go index 6cfe7e040..85811dbca 100644 --- a/storage/remote/queue_manager.go +++ b/storage/remote/queue_manager.go @@ -149,7 +149,7 @@ type QueueManager struct { queueName string logLimiter *rate.Limiter - shardsMtx sync.Mutex + shardsMtx sync.RWMutex shards *shards numShards int reshardChan chan int @@ -218,9 +218,9 @@ func (t *QueueManager) Append(s *model.Sample) error { return nil } - t.shardsMtx.Lock() + t.shardsMtx.RLock() enqueued := t.shards.enqueue(&snew) - t.shardsMtx.Unlock() + t.shardsMtx.RUnlock() if enqueued { queueLength.WithLabelValues(t.queueName).Inc()