2022-10-19 18:23:27 +08:00
|
|
|
package datanode
|
|
|
|
|
|
|
|
import (
|
2023-06-28 14:54:45 +08:00
|
|
|
"runtime"
|
2022-10-19 18:23:27 +08:00
|
|
|
"sync"
|
|
|
|
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/conc"
|
2022-10-19 18:23:27 +08:00
|
|
|
)
|
|
|
|
|
2023-04-19 23:56:31 +08:00
|
|
|
var ioPool *conc.Pool[any]
|
2022-10-19 18:23:27 +08:00
|
|
|
var ioPoolInitOnce sync.Once
|
|
|
|
|
2023-06-28 14:54:45 +08:00
|
|
|
var statsPool *conc.Pool[any]
|
|
|
|
var statsPoolInitOnce sync.Once
|
|
|
|
|
2022-10-19 18:23:27 +08:00
|
|
|
func initIOPool() {
|
2022-12-07 18:01:19 +08:00
|
|
|
capacity := Params.DataNodeCfg.IOConcurrency.GetAsInt()
|
2022-10-19 18:23:27 +08:00
|
|
|
if capacity > 32 {
|
|
|
|
capacity = 32
|
|
|
|
}
|
|
|
|
// error only happens with negative expiry duration or with negative pre-alloc size.
|
2023-04-19 23:56:31 +08:00
|
|
|
ioPool = conc.NewPool[any](capacity)
|
2022-10-19 18:23:27 +08:00
|
|
|
}
|
|
|
|
|
2023-04-19 23:56:31 +08:00
|
|
|
func getOrCreateIOPool() *conc.Pool[any] {
|
2022-10-19 18:23:27 +08:00
|
|
|
ioPoolInitOnce.Do(initIOPool)
|
|
|
|
return ioPool
|
|
|
|
}
|
2023-06-28 14:54:45 +08:00
|
|
|
|
|
|
|
func initStatsPool() {
|
|
|
|
statsPool = conc.NewPool[any](runtime.GOMAXPROCS(0), conc.WithPreAlloc(false), conc.WithNonBlocking(false))
|
|
|
|
}
|
|
|
|
|
|
|
|
func getOrCreateStatsPool() *conc.Pool[any] {
|
|
|
|
statsPoolInitOnce.Do(initStatsPool)
|
|
|
|
return statsPool
|
|
|
|
}
|