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