From be3616b6b391ae16709260c0b199f20be2330ef7 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Fri, 9 Sep 2016 16:11:06 +0200 Subject: [PATCH] ArchiveChecker: use MAX_LOAD_FACTOR constant --- borg/archive.py | 5 +++-- borg/testsuite/hashindex.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/borg/archive.py b/borg/archive.py index a3a133171..e6dd39557 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -853,8 +853,9 @@ class ArchiveChecker: """Fetch a list of all object keys from repository """ # Explicitly set the initial hash table capacity to avoid performance issues - # due to hash table "resonance" - capacity = int(len(self.repository) * 1.35 + 1) # > len * 1.0 / HASH_MAX_LOAD (see _hashindex.c) + # due to hash table "resonance". + # Since reconstruction of archive items can add some new chunks, add 10 % headroom + capacity = int(len(self.repository) / ChunkIndex.MAX_LOAD_FACTOR * 1.1) self.chunks = ChunkIndex(capacity) marker = None while True: diff --git a/borg/testsuite/hashindex.py b/borg/testsuite/hashindex.py index b81cbf47f..629ae4e57 100644 --- a/borg/testsuite/hashindex.py +++ b/borg/testsuite/hashindex.py @@ -279,5 +279,5 @@ def test_nsindex_segment_limit(): def test_max_load_factor(): - assert NSIndex.MAX_LOAD_FACTOR < 1 - assert ChunkIndex.MAX_LOAD_FACTOR < 1 + assert NSIndex.MAX_LOAD_FACTOR < 1.0 + assert ChunkIndex.MAX_LOAD_FACTOR < 1.0