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
}
_ = this.sync(true)
// TODO 决定是否同步
//_ = this.sync(true)
this.isClosed = true

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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)