]> arthur.barton.de Git - bup.git/commit
mincore: fix reading information
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 1 May 2020 20:16:39 +0000 (22:16 +0200)
committerRob Browning <rlb@defaultvalue.org>
Mon, 11 May 2020 02:01:53 +0000 (21:01 -0500)
commite92268976759f10f93fee4418c169390c1d9bc85
treee0ed7555bd490e68fe8002700c3623b0b4b807fa
parentc1e027d8e47837ee1cc29a7dd75266a8704bd3ef
mincore: fix reading information

The _fmincore_chunk_size is typically set to 64MiB, which
makes sense to avoid doing very large mmap() operations
(to save already precious VM on 32-bit systems).

However, since that's in bytes, we cannot divide a size in
pages by it, and expect any useful outcome.

Calculate the number of chunks (chunk_count) properly based
on the size of the file, rather than its number of pages.
Otherwise, chunk_count typically ends up just 1 even for a
very large file (my test file was ~500MiB), and mincore()
is run just once, so we fill the presence information only
for the first 64MiB of the file, even if it was previously
completely in RAM.

Given a large enough test file (and enough RAM to keep it
there), the following should print about the same times
twice:

  cat test > /dev/null ; \
  time cat test > /dev/null ; \
  bup split --noop test ; \
  time cat test >/dev/null

Without the fix, it's evident that the file is evicted from
RAM almost entirely (apart from the first 64MiB) even in
this synthetic case.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
(cherry picked from commit f41b3ab13ca1d740d30241692f6ec4e98c66cd27)
lib/bup/helpers.py