aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-18 00:00:00 +0000
committerGravatar Runxi Yu2025-11-18 00:00:00 +0000
commit5cf92cc63647a15eeb544256aa56cd8191a3fb6b (patch)
treef2e05bd979964a8910b45755811606fafd880496
parenthare-git history (diff)
signature
madvise
-rw-r--r--pack_pack.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pack_pack.go b/pack_pack.go
index 75cd282e..fb2d965e 100644
--- a/pack_pack.go
+++ b/pack_pack.go
@@ -533,6 +533,18 @@ func openPackFile(absPath, rel string) (*packFile, error) {
_ = syscall.Munmap(region)
return nil, err
}
+
+ err = syscall.Madvise(region, syscall.MADV_RANDOM)
+ if err != nil {
+ _ = syscall.Munmap(region)
+ return nil, err
+ }
+ err = syscall.Madvise(region, syscall.MADV_WILLNEED)
+ if err != nil {
+ _ = syscall.Munmap(region)
+ return nil, err
+ }
+
return &packFile{
relPath: rel,
size: stat.Size(),