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