changeset 94:8352da172a3e

Use "fadvise()" with POSIX_FADV_SEQUENTIAL -- if available
author Franz Glasner <f.glasner@feldmann-mg.com>
date Thu, 21 Apr 2022 16:01:19 +0200
parents 06b2a504b8f6
children fc2dd6afd594
files cutils/shasum.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/shasum.py	Thu Apr 21 09:18:23 2022 +0200
+++ b/cutils/shasum.py	Thu Apr 21 16:01:19 2022 +0200
@@ -597,6 +597,9 @@
             use_mmap = True
         if mmap is None or not use_mmap:
             # No mmap available or wanted -> use traditional low-level file IO
+            fadvise = getattr(os, "posix_fadvise", None)
+            if fadvise:
+                fadvise(fd, 0, 0, os.POSIX_FADV_SEQUENTIAL)
             while True:
                 try:
                     buf = os.read(fd, READ_CHUNK_SIZE)