From: Rob Browning Date: Sun, 28 Jun 2015 12:07:55 +0000 (-0500) Subject: Move _page_size to helpers.sc_page_size X-Git-Tag: 0.28-rc1~80 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=2660592aa67e987fb5ab8351ecea142faedc8e53 Move _page_size to helpers.sc_page_size Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/hashsplit.py b/lib/bup/hashsplit.py index cafbc98..5df627f 100644 --- a/lib/bup/hashsplit.py +++ b/lib/bup/hashsplit.py @@ -1,14 +1,13 @@ import math, os from bup import _helpers +from bup.helpers import sc_page_size try: _fmincore = _helpers.fmincore except AttributeError, e: _fmincore = None -_page_size = os.sysconf("SC_PAGE_SIZE") - BLOB_MAX = 8192*4 # 8192 is the "typical" blob size for bupsplit BLOB_READ_SIZE = 1024*1024 MAX_PER_TREE = 256 @@ -52,7 +51,9 @@ def _fadvise_pages_done(fd, first_page, count): assert(first_page >= 0) assert(count >= 0) if count > 0: - _helpers.fadvise_done(fd, first_page * _page_size, count * _page_size) + _helpers.fadvise_done(fd, + first_page * sc_page_size, + count * sc_page_size) def _nonresident_page_regions(status_bytes, max_region_len=None): @@ -85,7 +86,7 @@ def _uncache_ours_upto(fd, offset, first_region, remaining_regions): (start_page, count) pair. The final region must have a start_page of None.""" rstart, rlen = first_region - while rstart is not None and (rstart + rlen) * _page_size <= offset: + while rstart is not None and (rstart + rlen) * sc_page_size <= offset: _fadvise_pages_done(fd, rstart, rlen) rstart, rlen = next(remaining_regions, (None, None)) return (rstart, rlen) @@ -98,7 +99,7 @@ def readfile_iter(files, progress=None): fd = rpr = rstart = rlen = None if _fmincore and hasattr(f, 'fileno'): fd = f.fileno() - max_chunk = max(1, (8 * 1024 * 1024) / _page_size) + max_chunk = max(1, (8 * 1024 * 1024) / sc_page_size) rpr = _nonresident_page_regions(_helpers.fmincore(fd), max_chunk) rstart, rlen = next(rpr, (None, None)) while 1: diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index 9e42884..a9142c6 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -9,6 +9,7 @@ import hashlib, heapq, math, operator, time, grp, tempfile from bup import _helpers +sc_page_size = os.sysconf('SC_PAGE_SIZE') sc_arg_max = os.sysconf('SC_ARG_MAX') # This function should really be in helpers, not in bup.options. But we diff --git a/lib/bup/t/thashsplit.py b/lib/bup/t/thashsplit.py index 8b52acf..7ddcf34 100644 --- a/lib/bup/t/thashsplit.py +++ b/lib/bup/t/thashsplit.py @@ -1,7 +1,10 @@ -from bup import hashsplit, _helpers -from wvtest import * from cStringIO import StringIO +from wvtest import * + +from bup import hashsplit, _helpers, helpers + + def nr_regions(x, max_count=None): return list(hashsplit._nonresident_page_regions(''.join(map(chr, x)), max_count)) @@ -47,7 +50,7 @@ def test_uncache_ours_upto(): history.append((f, ofs, len)) uncache_upto = hashsplit._uncache_ours_upto - page_size = os.sysconf("SC_PAGE_SIZE") + page_size = helpers.sc_page_size orig_pages_done = hashsplit._fadvise_pages_done try: hashsplit._fadvise_pages_done = mock_fadvise_pages_done