From 6d4269defb20d1ebf692d6d131b285b0ea56a45f Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 30 Apr 2024 12:38:43 +0800 Subject: [PATCH] bfs commit --- internal/utils/bfs/blocks_file.go | 3 ++- internal/utils/bfs/fs.go | 5 +++++ internal/utils/bfs/fs_options.go | 6 +++--- internal/utils/bfs/threads_limiter.go | 1 - 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/utils/bfs/blocks_file.go b/internal/utils/bfs/blocks_file.go index 4375573..f9bce3a 100644 --- a/internal/utils/bfs/blocks_file.go +++ b/internal/utils/bfs/blocks_file.go @@ -316,7 +316,8 @@ func (this *BlocksFile) Close() error { return nil } - _ = this.sync(true) + // TODO 决定是否同步 + //_ = this.sync(true) this.isClosed = true diff --git a/internal/utils/bfs/fs.go b/internal/utils/bfs/fs.go index 15ed096..0a188bd 100644 --- a/internal/utils/bfs/fs.go +++ b/internal/utils/bfs/fs.go @@ -256,6 +256,11 @@ func (this *FS) openBFileForHashWriting(hash string) (*BlocksFile, error) { if ok { // 调整当前BFile所在位置 this.mu.Lock() + + if bFile.IsClosing() { + // TODO 需要重新等待打开 + } + item, itemOk := this.bItemMap[bName] if itemOk { this.bList.Remove(item) diff --git a/internal/utils/bfs/fs_options.go b/internal/utils/bfs/fs_options.go index 598a39e..57436aa 100644 --- a/internal/utils/bfs/fs_options.go +++ b/internal/utils/bfs/fs_options.go @@ -18,9 +18,9 @@ type FSOptions struct { func (this *FSOptions) EnsureDefaults() { if this.MaxOpenFiles <= 0 { // 根据内存计算最大打开文件数 - var maxOpenFiles = memutils.SystemMemoryGB() * 64 - if maxOpenFiles > (4 << 10) { - maxOpenFiles = 4 << 10 + var maxOpenFiles = memutils.SystemMemoryGB() * 128 + if maxOpenFiles > (8 << 10) { + maxOpenFiles = 8 << 10 } this.MaxOpenFiles = maxOpenFiles } diff --git a/internal/utils/bfs/threads_limiter.go b/internal/utils/bfs/threads_limiter.go index 93f291a..be8912b 100644 --- a/internal/utils/bfs/threads_limiter.go +++ b/internal/utils/bfs/threads_limiter.go @@ -4,7 +4,6 @@ package bfs import "github.com/TeaOSLab/EdgeNode/internal/zero" -// TODO 使用atomic代替channel?需要使用基准测试对比性能 // TODO 线程数可以根据硬盘数量动态调整? var readThreadsLimiter = make(chan zero.Zero, 8) var writeThreadsLimiter = make(chan zero.Zero, 8)