From e6e3485acd6b6dd3802883ac2d3a2fff26745eb8 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 30 Jul 2023 09:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 2 -- internal/caches/storage_memory.go | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index 2aa3030..a8e5acf 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -61,8 +61,6 @@ const ( var sharedWritingFileKeyMap = map[string]zero.Zero{} // key => bool var sharedWritingFileKeyLocker = sync.Mutex{} -const protectingLoadWhenDump = false - // FileStorage 文件缓存 // // 文件结构: diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index f432a9d..80ead0d 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -7,6 +7,7 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/trackers" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" setutils "github.com/TeaOSLab/EdgeNode/internal/utils/sets" "github.com/TeaOSLab/EdgeNode/internal/utils/sizes" "github.com/TeaOSLab/EdgeNode/internal/zero" @@ -483,7 +484,8 @@ func (this *MemoryStorage) startFlush() { if statCount == 100 { statCount = 0 - if protectingLoadWhenDump { + // delay some time to reduce load if needed + if !fsutils.DiskIsFast { loadStat, err := load.Avg() if err == nil && loadStat != nil { if loadStat.Load1 > 10 {