MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / EnsureDefaults

Method EnsureDefaults

internal/utils/bfs/fs_options.go:18–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18func (this *FSOptions) EnsureDefaults() {
19 if this.MaxOpenFiles <= 0 {
20 // 根据内存计算最大打开文件数
21 var maxOpenFiles = memutils.SystemMemoryGB() * 128
22 if maxOpenFiles > (8 << 10) {
23 maxOpenFiles = 8 << 10
24 }
25 this.MaxOpenFiles = maxOpenFiles
26 }
27 if this.BytesPerSync <= 0 {
28 if fsutils.DiskIsFast() {
29 this.BytesPerSync = 1 << 20 // TODO 根据硬盘实际写入速度进行调整
30 } else {
31 this.BytesPerSync = 512 << 10
32 }
33 }
34 if this.SyncTimeout <= 0 {
35 this.SyncTimeout = 1 * time.Second
36 }
37 if this.MaxSyncFiles <= 0 {
38 this.MaxSyncFiles = 32
39 }
40}
41
42var DefaultFSOptions = &FSOptions{
43 MaxOpenFiles: 1 << 10,

Callers 2

OpenFSFunction · 0.45
NewBlocksFileWithRawFileFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected