From d5c312629e2cd72242c00b446149721bda636849 Mon Sep 17 00:00:00 2001 From: Aidan Hobson Sayers Date: Sun, 25 Jan 2015 23:50:27 +0000 Subject: [PATCH] Don't fadvise we don't need data that we do need The documentation for posix_fadvise states that if len is 0 the advice extends to the end of the file. We currently always pass 0 for the first two posix_fadvise calls (first because ofs is 0, second because ofs == BLOB_READ_SIZE == 1024*1024) so we're advising the kernel to dump any predicted file caching twice per file. This patch ensures we don't pass a len of 0 in the two scenarios above. Signed-off-by: Aidan Hobson Sayers [rlb@defaultvalue.org: adjust commit summary] Reviewed-by: Rob Browning Tested-by: Rob Browning --- lib/bup/hashsplit.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bup/hashsplit.py b/lib/bup/hashsplit.py index 72ea20d..571ddf6 100644 --- a/lib/bup/hashsplit.py +++ b/lib/bup/hashsplit.py @@ -48,11 +48,12 @@ def readfile_iter(files, progress=None): while 1: if progress: progress(filenum, len(b)) - fadvise_done(f, max(0, ofs - 1024*1024)) b = f.read(BLOB_READ_SIZE) ofs += len(b) + # Warning: ofs == 0 means 'done with the whole file' + # This will only happen here when the file is empty + fadvise_done(f, ofs) if not b: - fadvise_done(f, ofs) break yield b -- 2.39.2