mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-06 01:50:26 +08:00
根据系统环境动态调整内容刷入磁盘线程数
This commit is contained in:
@@ -99,10 +99,19 @@ func (this *MemoryStorage) Init() error {
|
|||||||
|
|
||||||
// 启动定时Flush memory to disk任务
|
// 启动定时Flush memory to disk任务
|
||||||
if this.parentStorage != nil {
|
if this.parentStorage != nil {
|
||||||
// TODO 应该根据磁盘性能决定线程数
|
var threads = 2
|
||||||
// TODO 线程数应该可以在缓存策略和节点中设定
|
var numCPU = runtime.NumCPU()
|
||||||
var threads = runtime.NumCPU()
|
if fsutils.DiskIsExtremelyFast() {
|
||||||
|
if numCPU >= 8 {
|
||||||
|
threads = 8
|
||||||
|
} else {
|
||||||
|
threads = 4
|
||||||
|
}
|
||||||
|
} else if fsutils.DiskIsFast() {
|
||||||
|
if numCPU >= 4 {
|
||||||
|
threads = 4
|
||||||
|
}
|
||||||
|
}
|
||||||
for i := 0; i < threads; i++ {
|
for i := 0; i < threads; i++ {
|
||||||
goman.New(func() {
|
goman.New(func() {
|
||||||
this.startFlush()
|
this.startFlush()
|
||||||
|
|||||||
Reference in New Issue
Block a user