From 5ad25e34c6993822714edee49e00c29c8c45dfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 28 Sep 2023 10:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=BF=AB=E9=80=9F=E7=A1=AC?= =?UTF-8?q?=E7=9B=98=E6=B8=85=E7=90=86=E8=BF=87=E6=9C=9F=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index ca23cc3..6a41f3d 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -1034,23 +1034,36 @@ func (this *FileStorage) purgeLoop() { // 空闲时间多清理 systemLoad, _ := load.Avg() if systemLoad != nil { - if systemLoad.Load5 < 2 { + if systemLoad.Load5 < 3 { times = 5 - } else if systemLoad.Load5 < 3 { - times = 3 } else if systemLoad.Load5 < 5 { + times = 3 + } else if systemLoad.Load5 < 10 { times = 2 } } + // 高速硬盘多清理 + if fsutils.DiskIsExtremelyFast() { + times *= 8 + } else if fsutils.DiskIsFast() { + times *= 4 + } + // 处于LFU阈值时,多清理 if startLFU { - times = 5 + times *= 5 } var purgeCount = this.policy.PersistenceAutoPurgeCount if purgeCount <= 0 { purgeCount = 1000 + + if fsutils.DiskIsExtremelyFast() { + purgeCount = 4000 + } else if fsutils.DiskIsFast() { + purgeCount = 2000 + } } for i := 0; i < times; i++ { countFound, err := this.list.Purge(purgeCount, func(hash string) error { @@ -1080,10 +1093,10 @@ func (this *FileStorage) purgeLoop() { var maxCount = 2000 var maxLoops = 5 - if fsutils.DiskIsFast() { - maxCount = 5000 - } else if fsutils.DiskIsExtremelyFast() { + if fsutils.DiskIsExtremelyFast() { maxCount = 10000 + } else if fsutils.DiskIsFast() { + maxCount = 5000 } var total, _ = this.list.Count()