bfs commit

This commit is contained in:
GoEdgeLab
2024-04-30 12:38:43 +08:00
parent 47860b1e4d
commit 6d4269defb
4 changed files with 10 additions and 5 deletions

View File

@@ -316,7 +316,8 @@ func (this *BlocksFile) Close() error {
return nil return nil
} }
_ = this.sync(true) // TODO 决定是否同步
//_ = this.sync(true)
this.isClosed = true this.isClosed = true

View File

@@ -256,6 +256,11 @@ func (this *FS) openBFileForHashWriting(hash string) (*BlocksFile, error) {
if ok { if ok {
// 调整当前BFile所在位置 // 调整当前BFile所在位置
this.mu.Lock() this.mu.Lock()
if bFile.IsClosing() {
// TODO 需要重新等待打开
}
item, itemOk := this.bItemMap[bName] item, itemOk := this.bItemMap[bName]
if itemOk { if itemOk {
this.bList.Remove(item) this.bList.Remove(item)

View File

@@ -18,9 +18,9 @@ type FSOptions struct {
func (this *FSOptions) EnsureDefaults() { func (this *FSOptions) EnsureDefaults() {
if this.MaxOpenFiles <= 0 { if this.MaxOpenFiles <= 0 {
// 根据内存计算最大打开文件数 // 根据内存计算最大打开文件数
var maxOpenFiles = memutils.SystemMemoryGB() * 64 var maxOpenFiles = memutils.SystemMemoryGB() * 128
if maxOpenFiles > (4 << 10) { if maxOpenFiles > (8 << 10) {
maxOpenFiles = 4 << 10 maxOpenFiles = 8 << 10
} }
this.MaxOpenFiles = maxOpenFiles this.MaxOpenFiles = maxOpenFiles
} }

View File

@@ -4,7 +4,6 @@ package bfs
import "github.com/TeaOSLab/EdgeNode/internal/zero" import "github.com/TeaOSLab/EdgeNode/internal/zero"
// TODO 使用atomic代替channel需要使用基准测试对比性能
// TODO 线程数可以根据硬盘数量动态调整? // TODO 线程数可以根据硬盘数量动态调整?
var readThreadsLimiter = make(chan zero.Zero, 8) var readThreadsLimiter = make(chan zero.Zero, 8)
var writeThreadsLimiter = make(chan zero.Zero, 8) var writeThreadsLimiter = make(chan zero.Zero, 8)