From 0f5f03c9ed964c1d6685f95b1d74c232cfc3caeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Tue, 26 Jul 2022 08:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88IO=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 3 ++- internal/caches/storage_memory.go | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index 321fedc..a8303ca 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -65,7 +65,8 @@ var sharedWritingFileKeyLocker = sync.Mutex{} var maxOpenFiles = NewMaxOpenFiles() -const maxOpenFilesSlowCost = 500 * time.Microsecond // 0.5ms +const maxOpenFilesSlowCost = 5000 * time.Microsecond // 0.5ms +const protectingLoadWhenDump = false // FileStorage 文件缓存 // 文件结构: diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index 3bb0e6d..90e4df6 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -438,16 +438,18 @@ func (this *MemoryStorage) startFlush() { if statCount == 100 { statCount = 0 - loadStat, err := load.Avg() - if err == nil && loadStat != nil { - if loadStat.Load1 > 10 { - writeDelayMS = 100 - } else if loadStat.Load1 > 3 { - writeDelayMS = 50 - } else if loadStat.Load1 > 2 { - writeDelayMS = 10 - } else { - writeDelayMS = 0 + if protectingLoadWhenDump { + loadStat, err := load.Avg() + if err == nil && loadStat != nil { + if loadStat.Load1 > 10 { + writeDelayMS = 100 + } else if loadStat.Load1 > 3 { + writeDelayMS = 50 + } else if loadStat.Load1 > 2 { + writeDelayMS = 10 + } else { + writeDelayMS = 0 + } } } }