()
| 16 | } |
| 17 | |
| 18 | func (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 | |
| 42 | var DefaultFSOptions = &FSOptions{ |
| 43 | MaxOpenFiles: 1 << 10, |
no outgoing calls
no test coverage detected