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 c22da2f917
This commit is contained in:
Aliaksandr Valialkin 2024-04-20 21:39:49 +02:00
parent c22da2f917
commit 1decbcf6eb
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -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())