🚀 perf: Performance and Memory optimization

This commit is contained in:
2026-07-17 01:28:35 +07:00
parent facdb35d5d
commit 6d221846df
5 changed files with 100 additions and 21 deletions
+9
View File
@@ -28,6 +28,8 @@ func readFrameFile(filename string) (*frameFile, error) {
data, err := os.ReadFile(filename)
return &frameFile{data: data}, err
}
_ = syscall.Madvise(data, syscall.MADV_RANDOM)
return &frameFile{
data: data,
cleanup: func() error {
@@ -35,3 +37,10 @@ func readFrameFile(filename string) (*frameFile, error) {
},
}, nil
}
func (f *frameFile) dropResident() {
if f == nil || f.cleanup == nil || len(f.data) == 0 {
return
}
_ = syscall.Madvise(f.data, syscall.MADV_DONTNEED)
}