From 1decbcf6ebbc85e41a9c643ca95178cb4654eb0c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 20 Apr 2024 21:39:49 +0200 Subject: [PATCH] app/vminsert/influx: replace hybrid channel-based pool+sync.Pool with plain sync.Pool for pushCtx The memory usage for plain sync.Pool doesn't increase comparing to the memory usage for the hybrid scheme, so it is better to use plain sync.Pool in order to simplify the code and make it more readable and maintainable. This is a follow-up for c22da2f917bda55f21c55a8cd1249cb0f83479f9 --- app/vminsert/influx/request_handler.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/app/vminsert/influx/request_handler.go b/app/vminsert/influx/request_handler.go index 39108a188..d8476487c 100644 --- a/app/vminsert/influx/request_handler.go +++ b/app/vminsert/influx/request_handler.go @@ -166,25 +166,15 @@ func (ctx *pushCtx) reset() { } func getPushCtx() *pushCtx { - select { - case ctx := <-pushCtxPoolCh: - return ctx - default: - if v := pushCtxPool.Get(); v != nil { - return v.(*pushCtx) - } - return &pushCtx{} + if v := pushCtxPool.Get(); v != nil { + return v.(*pushCtx) } + return &pushCtx{} } func putPushCtx(ctx *pushCtx) { ctx.reset() - select { - case pushCtxPoolCh <- ctx: - default: - pushCtxPool.Put(ctx) - } + pushCtxPool.Put(ctx) } var pushCtxPool sync.Pool -var pushCtxPoolCh = make(chan *pushCtx, cgroup.AvailableCPUs())