summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-31 16:39:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-03-31 16:39:53 +0000
commit03b968b8fd27d838762b935b512297eca9192bb5 (patch)
tree4d8dfd9ce972ff873320a22278e7e892abaf3baf /vespalib
parent17e22dbe818d445816937a03cccd7b8065af5e85 (diff)
Inline frequently called find method to allow compiler better chance to start division early to hide its cost in teh pipeline.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp17
-rw-r--r--vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h15
2 files changed, 14 insertions, 18 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp
index 130abd0ba50..18476dc64a5 100644
--- a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp
+++ b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp
@@ -152,23 +152,6 @@ FixedSizeHashMap::remove(const ShardedHashComparator & comp)
return nullptr;
}
-FixedSizeHashMap::KvType*
-FixedSizeHashMap::find(const ShardedHashComparator & comp)
-{
- uint32_t hash_idx = comp.hash_idx() % _modulo;
- auto& chain_head = _chain_heads[hash_idx];
- uint32_t node_idx = chain_head.load_acquire();
- while (node_idx != no_node_idx) {
- auto &node = _nodes[node_idx];
- EntryRef node_key_ref = node.get_kv().first.load_acquire();
- if (node_key_ref.valid() && comp.equal(node_key_ref)) {
- return &_nodes[node_idx].get_kv();
- }
- node_idx = node.get_next_node_idx().load(std::memory_order_acquire);
- }
- return nullptr;
-}
-
MemoryUsage
FixedSizeHashMap::get_memory_usage() const
{
diff --git a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h
index 3ccf690af8e..b1c81744de2 100644
--- a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h
+++ b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h
@@ -125,7 +125,20 @@ public:
KvType& add(const ShardedHashComparator & comp, std::function<EntryRef(void)>& insert_entry);
KvType* remove(const ShardedHashComparator & comp);
- KvType* find(const ShardedHashComparator & comp);
+ KvType* find(const ShardedHashComparator & comp) {
+ uint32_t hash_idx = comp.hash_idx() % _modulo;
+ auto& chain_head = _chain_heads[hash_idx];
+ uint32_t node_idx = chain_head.load_acquire();
+ while (node_idx != no_node_idx) {
+ auto &node = _nodes[node_idx];
+ EntryRef node_key_ref = node.get_kv().first.load_acquire();
+ if (node_key_ref.valid() && comp.equal(node_key_ref)) {
+ return &_nodes[node_idx].get_kv();
+ }
+ node_idx = node.get_next_node_idx().load(std::memory_order_acquire);
+ }
+ return nullptr;
+ }
void transfer_hold_lists(generation_t generation) {
if (!_hold_1_list.empty()) {