From 874f5c491b504a83dd9da94e8ca5a8c5c30b0298 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 11 Apr 2015 02:40:22 +0200 Subject: [PATCH] use posix_fadvise for repo writes also --- attic/repository.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/attic/repository.py b/attic/repository.py index eed85dc43..592e5fe5d 100644 --- a/attic/repository.py +++ b/attic/repository.py @@ -555,6 +555,10 @@ def write_put(self, id, data): header = self.header_no_crc_fmt.pack(size, TAG_PUT) crc = self.crc_fmt.pack(crc32(data, crc32(id, crc32(header))) & 0xffffffff) fd.write(b''.join((crc, header, id, data))) + if hasattr(os, 'posix_fadvise'): # python >= 3.3, only on UNIX + # tell the OS that it does not need to cache what we just wrote, + # avoids spoiling the cache for the OS and other processes. + os.posix_fadvise(fd.fileno(), 0, 0, os.POSIX_FADV_DONTNEED) self.offset += size return self.segment, offset