From 128ecc27f242f8a37f717f1249985a8d9742e964 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 28 May 2020 07:38:58 +0100 Subject: [PATCH] [space-maps] remove count_possibly_greater_than_one This is only ever called with a recursive space map wrapper, and that causes too many false positives. False positives trigger a copy of a metadata page, so this is a false economy. --- persistent-data/space-maps/careful_alloc.cc | 4 ---- persistent-data/space-maps/core.cc | 6 ------ persistent-data/space-maps/disk.cc | 4 ---- persistent-data/space-maps/noop.h | 5 ----- persistent-data/space-maps/recursive.cc | 10 ---------- persistent-data/space_map.h | 2 -- persistent-data/transaction_manager.cc | 2 +- 7 files changed, 1 insertion(+), 32 deletions(-) diff --git a/persistent-data/space-maps/careful_alloc.cc b/persistent-data/space-maps/careful_alloc.cc index 4609883..9e64cb1 100644 --- a/persistent-data/space-maps/careful_alloc.cc +++ b/persistent-data/space-maps/careful_alloc.cc @@ -77,10 +77,6 @@ namespace { return sm_->find_free(filtered_it); } - virtual bool count_possibly_greater_than_one(block_address b) const { - return sm_->count_possibly_greater_than_one(b); - } - virtual void extend(block_address extra_blocks) { return sm_->extend(extra_blocks); } diff --git a/persistent-data/space-maps/core.cc b/persistent-data/space-maps/core.cc index 6e1418c..463d212 100644 --- a/persistent-data/space-maps/core.cc +++ b/persistent-data/space-maps/core.cc @@ -43,7 +43,6 @@ namespace { void inc(block_address b, ref_t count) override; void dec(block_address b, ref_t count) override; maybe_block find_free(span_iterator &it) override; - bool count_possibly_greater_than_one(block_address b) const override; void extend(block_address extra_blocks) override; void count_metadata(block_counter &bc) const override; @@ -131,11 +130,6 @@ namespace { return maybe_block(); } - bool - core_map::count_possibly_greater_than_one(block_address b) const { - return get_count(b) > 1; - } - void core_map::extend(block_address extra_blocks) { throw std::runtime_error("'extend' not implemented"); diff --git a/persistent-data/space-maps/disk.cc b/persistent-data/space-maps/disk.cc index 51a4b78..28e13d3 100644 --- a/persistent-data/space-maps/disk.cc +++ b/persistent-data/space-maps/disk.cc @@ -429,10 +429,6 @@ namespace { return maybe_block(); } - bool count_possibly_greater_than_one(block_address b) const { - return get_count(b) > 1; - } - virtual void extend(block_address extra_blocks) { block_address nr_blocks = nr_blocks_ + extra_blocks; diff --git a/persistent-data/space-maps/noop.h b/persistent-data/space-maps/noop.h index 925936c..8f3660c 100644 --- a/persistent-data/space-maps/noop.h +++ b/persistent-data/space-maps/noop.h @@ -64,11 +64,6 @@ namespace persistent_data { return boost::optional(0); } - bool count_possibly_greater_than_one(block_address b) const { - fail(); - return false; - } - void extend(block_address extra_blocks) { fail(); } diff --git a/persistent-data/space-maps/recursive.cc b/persistent-data/space-maps/recursive.cc index 46d6ed5..dadbe88 100644 --- a/persistent-data/space-maps/recursive.cc +++ b/persistent-data/space-maps/recursive.cc @@ -132,16 +132,6 @@ namespace { return sm_->find_free(filtered_it); } - virtual bool count_possibly_greater_than_one(block_address b) const { - recursing_const_lock lock(*this); - - bool gto = sm_->count_possibly_greater_than_one(b); - if (gto) - return true; - - return modify_count(b, 1) > 1; - } - virtual void extend(block_address extra_blocks) { cant_recurse("extend"); recursing_lock lock(*this); diff --git a/persistent-data/space_map.h b/persistent-data/space_map.h index 930626a..15b6076 100644 --- a/persistent-data/space_map.h +++ b/persistent-data/space_map.h @@ -88,8 +88,6 @@ namespace persistent_data { virtual maybe_block find_free(span_iterator &it) = 0; - virtual bool count_possibly_greater_than_one(block_address b) const = 0; - virtual void extend(block_address extra_blocks) = 0; struct iterator { diff --git a/persistent-data/transaction_manager.cc b/persistent-data/transaction_manager.cc index 2bcdda7..a8b6c7b 100644 --- a/persistent-data/transaction_manager.cc +++ b/persistent-data/transaction_manager.cc @@ -62,7 +62,7 @@ transaction_manager::new_block(validator v) pair transaction_manager::shadow(block_address orig, validator v) { - bool need_inc = sm_->count_possibly_greater_than_one(orig); + bool need_inc = sm_->get_count(orig) > 1; if (is_shadow(orig) && !need_inc) return make_pair(bm_->write_lock(orig, v), need_inc);