mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
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:
parent
c22da2f917
commit
1decbcf6eb
1 changed files with 4 additions and 14 deletions
|
@ -166,25 +166,15 @@ func (ctx *pushCtx) reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPushCtx() *pushCtx {
|
func getPushCtx() *pushCtx {
|
||||||
select {
|
if v := pushCtxPool.Get(); v != nil {
|
||||||
case ctx := <-pushCtxPoolCh:
|
return v.(*pushCtx)
|
||||||
return ctx
|
|
||||||
default:
|
|
||||||
if v := pushCtxPool.Get(); v != nil {
|
|
||||||
return v.(*pushCtx)
|
|
||||||
}
|
|
||||||
return &pushCtx{}
|
|
||||||
}
|
}
|
||||||
|
return &pushCtx{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func putPushCtx(ctx *pushCtx) {
|
func putPushCtx(ctx *pushCtx) {
|
||||||
ctx.reset()
|
ctx.reset()
|
||||||
select {
|
pushCtxPool.Put(ctx)
|
||||||
case pushCtxPoolCh <- ctx:
|
|
||||||
default:
|
|
||||||
pushCtxPool.Put(ctx)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushCtxPool sync.Pool
|
var pushCtxPool sync.Pool
|
||||||
var pushCtxPoolCh = make(chan *pushCtx, cgroup.AvailableCPUs())
|
|
||||||
|
|
Loading…
Reference in a new issue