From e7fddcbc0419d1524940becae0b1e726b77a42ae Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Wed, 11 Jan 2017 00:47:01 -0500 Subject: [PATCH] hash: use the LockSet max_size to read hash table from only one thread at a time This reduces disk thrashing at startup. Signed-off-by: Zygo Blaxell --- src/bees-hash.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bees-hash.cc b/src/bees-hash.cc index 5cc2cb1..05e6980 100644 --- a/src/bees-hash.cc +++ b/src/bees-hash.cc @@ -595,6 +595,9 @@ BeesHashTable::BeesHashTable(shared_ptr ctx, string filename, off_t m_flush_rate_limit(BEES_FLUSH_RATE), m_stats_file(m_ctx->home_fd(), "beesstats.txt") { + // Reduce disk thrashing at startup: one reader at a time + m_extent_lock_set.max_size(1); + // Sanity checks to protect the implementation from its weaknesses THROW_CHECK2(invalid_argument, BLOCK_SIZE_HASHTAB_BUCKET, BLOCK_SIZE_HASHTAB_EXTENT, (BLOCK_SIZE_HASHTAB_EXTENT % BLOCK_SIZE_HASHTAB_BUCKET) == 0);