Refactor Makefile and enhance disk/memory eviction tests

- Updated the 'bench' target in the Makefile to run all benchmarks for MemoryFS and DiskFS, improving clarity and coverage.
- Added explicit post-eviction consistency checks in DiskFS tests to ensure on-disk files are removed after eviction.
- Introduced new benchmarks for memory eviction strategies under pressure, enhancing test coverage for memory management.
- Improved error handling in benchmark tests for both disk and memory file systems, ensuring robustness during performance evaluations.
- Refactored key generation in tests for consistency and clarity.
This commit is contained in:
2026-05-27 03:02:34 -05:00
parent 6f28362790
commit ffa9aa04f7
5 changed files with 317 additions and 26 deletions
+12
View File
@@ -357,6 +357,9 @@ func (m *MemoryFS) EvictBySize(bytesNeeded uint, ascending bool) uint {
var candidates []evictCandidate
for key, fi := range m.info {
candidates = append(candidates, evictCandidate{key: key, size: fi.Size})
if len(candidates) >= maxEvictBatch {
break
}
}
m.mu.RUnlock()
@@ -405,6 +408,9 @@ func (m *MemoryFS) EvictFIFO(bytesNeeded uint) uint {
key string
cTime time.Time
}{key: key, cTime: fi.CTime})
if len(candidates) >= maxEvictBatch {
break
}
}
m.mu.RUnlock()
@@ -451,6 +457,9 @@ func (m *MemoryFS) EvictLFU(bytesNeeded uint) uint {
accessCount int
aTime time.Time
}{key: key, accessCount: fi.AccessCount, aTime: fi.ATime})
if len(candidates) >= maxEvictBatch {
break
}
}
m.mu.RUnlock()
@@ -502,6 +511,9 @@ func (m *MemoryFS) EvictHybrid(bytesNeeded uint) uint {
accessCount int
aTime time.Time
}{key: key, accessCount: fi.AccessCount, aTime: fi.ATime})
if len(candidates) >= maxEvictBatch {
break
}
}
m.mu.RUnlock()