summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-01-20 12:43:05 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-01-20 12:43:05 +0000
commite7fa653562ee513322db0f7dca50568c3934a680 (patch)
tree590880f8c3a338282e2858e45c1437b9446fd593 /vespalib
parent48e3163e6ebab7cf161309e72549f32bcd4bf860 (diff)
Splitt force_insert into hot/cold parts.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hashtable.h1
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hashtable.hpp32
2 files changed, 20 insertions, 13 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.h b/vespalib/src/vespa/vespalib/stllike/hashtable.h
index 8665b4d235e..553cda1e6c0 100644
--- a/vespalib/src/vespa/vespalib/stllike/hashtable.h
+++ b/vespalib/src/vespa/vespalib/stllike/hashtable.h
@@ -363,6 +363,7 @@ private:
}
template <typename MoveHandler>
VESPA_DLL_LOCAL void reclaim(MoveHandler & moveHandler, next_t node);
+ VESPA_DLL_LOCAL void force_insert_cold(Value && value, next_t node) __attribute__((noinline));
};
}
diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.hpp b/vespalib/src/vespa/vespalib/stllike/hashtable.hpp
index f60e98c350e..1b12bfba427 100644
--- a/vespalib/src/vespa/vespalib/stllike/hashtable.hpp
+++ b/vespalib/src/vespa/vespalib/stllike/hashtable.hpp
@@ -185,23 +185,29 @@ hashtable<Key, Value, Hash, Equal, KeyExtract, Modulator>::insertInternal(V && n
template <typename Key, typename Value, typename Hash, typename Equal, typename KeyExtract, typename Modulator>
void
-hashtable<Key, Value, Hash, Equal, KeyExtract, Modulator>::force_insert(Value && value)
-{
+hashtable<Key, Value, Hash, Equal, KeyExtract, Modulator>::force_insert(Value && value) {
const next_t h = hash(_keyExtractor(value));
- if ( ! _nodes[h].valid() ) [[likely]] {
+ if (!_nodes[h].valid()) [[likely]] {
_nodes[h] = std::move(value);
_count++;
} else {
- if (_nodes.size() < _nodes.capacity()) [[likely]] {
- const next_t p(_nodes[h].getNext());
- const next_t newIdx(_nodes.size());
- _nodes[h].setNext(newIdx);
- _nodes.template emplace_back(std::move(value), p);
- _count++;
- } else {
- resize(_nodes.capacity()*2);
- force_insert(std::move(value));
- }
+ force_insert_cold(std::move(value), h);
+ }
+}
+
+template <typename Key, typename Value, typename Hash, typename Equal, typename KeyExtract, typename Modulator>
+void
+hashtable<Key, Value, Hash, Equal, KeyExtract, Modulator>::force_insert_cold(Value && value, next_t h)
+{
+ if (_nodes.size() < _nodes.capacity()) [[likely]] {
+ const next_t p(_nodes[h].getNext());
+ const next_t newIdx(_nodes.size());
+ _nodes[h].setNext(newIdx);
+ _nodes.template emplace_back(std::move(value), p);
+ _count++;
+ } else {
+ resize(_nodes.capacity()*2);
+ force_insert(std::move(value));
}
}