diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-01 13:04:47 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-01 13:04:47 +0000 |
commit | fe56302d4ee9a7725ff445e1dcb4f07f57b661c1 (patch) | |
tree | 544093fb9c3d1f274851e90cfeb7f5690abe5e14 | |
parent | 179daa38c12471ec9de4e48ec91865c8a336d8a8 (diff) |
Deinline unique_store_remapper
8 files changed, 81 insertions, 39 deletions
diff --git a/vespalib/src/apps/vespa-tsan-digest/tsan_digest.cpp b/vespalib/src/apps/vespa-tsan-digest/tsan_digest.cpp index d015cdb0f89..b5040583d3a 100644 --- a/vespalib/src/apps/vespa-tsan-digest/tsan_digest.cpp +++ b/vespalib/src/apps/vespa-tsan-digest/tsan_digest.cpp @@ -115,9 +115,11 @@ private: bool _is_read; bool _is_write; public: - StackTrace(const vespalib::string &heading) noexcept - : _heading(heading), _frames(), _hash(), _is_read(false), _is_write(false) {} - ~StackTrace() {} + StackTrace(const vespalib::string &heading) noexcept; + StackTrace(const StackTrace &); + StackTrace(StackTrace &&) noexcept; + StackTrace & operator=(StackTrace &&) noexcept; + ~StackTrace(); void add_frame(const vespalib::string &frame) { _frames.push_back(frame); } @@ -149,7 +151,16 @@ public: } }; -std::vector<StackTrace> extract_traces(const std::vector<vespalib::string> &lines, size_t cutoff) { +StackTrace::StackTrace(const vespalib::string &heading) noexcept + : _heading(heading), _frames(), _hash(), _is_read(false), _is_write(false) +{} +StackTrace::StackTrace(const StackTrace &) = default; +StackTrace::StackTrace(StackTrace &&) noexcept = default; +StackTrace & StackTrace::operator=(StackTrace &&) noexcept = default; +StackTrace::~StackTrace() = default; + +std::vector<StackTrace> +extract_traces(const std::vector<vespalib::string> &lines, size_t cutoff) { std::vector<StackTrace> result; for (size_t i = 1; (i < lines.size()) && (result.size() < cutoff); ++i) { auto pos = lines[i].find("#0 "); diff --git a/vespalib/src/tests/datastore/array_store/array_store_test.cpp b/vespalib/src/tests/datastore/array_store/array_store_test.cpp index 69df94f7181..210c18ddb29 100644 --- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp +++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp @@ -54,12 +54,13 @@ struct ArrayStoreTest : public TestT generation(1), add_using_allocate(add_using_allocate_in) {} - ArrayStoreTest(const ArrayStoreConfig &storeCfg) + explicit ArrayStoreTest(const ArrayStoreConfig &storeCfg) : store(storeCfg, std::make_unique<MemoryAllocatorObserver>(stats)), refStore(), generation(1), add_using_allocate(false) {} + ~ArrayStoreTest() override; void assertAdd(const EntryVector &input) { EntryRef ref = add(input); assertGet(ref, input); @@ -163,6 +164,9 @@ struct ArrayStoreTest : public TestT size_t largeArraySize() const { return sizeof(LargeArray); } }; +template <typename TestT, typename EntryT, typename RefT> +ArrayStoreTest<TestT, EntryT, RefT>::~ArrayStoreTest() = default; + struct TestParam { bool add_using_allocate; TestParam(bool add_using_allocate_in) : add_using_allocate(add_using_allocate_in) {} diff --git a/vespalib/src/tests/unwind_message/unwind_message_test.cpp b/vespalib/src/tests/unwind_message/unwind_message_test.cpp index f9f4824f317..ff0ee060ded 100644 --- a/vespalib/src/tests/unwind_message/unwind_message_test.cpp +++ b/vespalib/src/tests/unwind_message/unwind_message_test.cpp @@ -20,17 +20,21 @@ struct MyObj { UnwindMessage msg1 = UnwindMessage("this SHOULD be printed (1/4)"); UnwindMessage msg2 = UnwindMessage("this should NOT be printed (1)"); UnwindMessage msg3 = UnwindMessage("this SHOULD be printed (2/4)"); - ~MyObj() { - EXPECT_EQ(std::uncaught_exceptions(), 1); - auto not_printed_1 = std::move(msg2); - try { - MyCheck my_check; - auto printed_1 = std::move(msg1); - throw E("next level"); - } catch (const E &) {} - } + MyObj(); + ~MyObj(); }; +MyObj::MyObj() = default; +MyObj::~MyObj() { + EXPECT_EQ(std::uncaught_exceptions(), 1); + auto not_printed_1 = std::move(msg2); + try { + MyCheck my_check; + auto printed_1 = std::move(msg1); + throw E("next level"); + } catch (const E &) {} +} + TEST(UnwindMessageTest, unwind_messages_are_printed_when_appropriate) { auto not_printed_5 = unwind_msg("this should NOT be printed (%d)", 5); UNWIND_MSG("this should NOT be printed (%d)", 4); diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp index b8493017020..d9d5f9fee7f 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -10,6 +10,7 @@ #include "unique_store_builder.hpp" #include "unique_store_dictionary.hpp" #include "unique_store_enumerator.hpp" +#include "unique_store_remapper.hpp" #include <atomic> #include <algorithm> diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.h b/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.h index 174c74a62d2..06c74ab0d4f 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.h @@ -22,33 +22,12 @@ protected: EntryRefFilter _filter; std::vector<std::vector<EntryRef, allocator_large<EntryRef>>> _mapping; public: - UniqueStoreRemapper(EntryRefFilter&& filter) - : _filter(std::move(filter)), - _mapping() - { - } - virtual ~UniqueStoreRemapper() = default; - - EntryRef remap(EntryRef ref) const { - RefType internal_ref(ref); - auto &inner_mapping = _mapping[internal_ref.bufferId()]; - assert(internal_ref.offset() < inner_mapping.size()); - EntryRef mapped_ref = inner_mapping[internal_ref.offset()]; - assert(mapped_ref.valid()); - return mapped_ref; - } - - void remap(vespalib::ArrayRef<AtomicEntryRef> refs) const { - for (auto &atomic_ref : refs) { - auto ref = atomic_ref.load_relaxed(); - if (ref.valid() && _filter.has(ref)) { - atomic_ref.store_release(remap(ref)); - } - } - } + UniqueStoreRemapper(EntryRefFilter&& filter); + virtual ~UniqueStoreRemapper(); + EntryRef remap(EntryRef ref) const; + void remap(vespalib::ArrayRef<AtomicEntryRef> refs) const; const EntryRefFilter& get_entry_ref_filter() const noexcept { return _filter; } - virtual void done() = 0; }; diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.hpp new file mode 100644 index 00000000000..5d8a4d7ec6f --- /dev/null +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_remapper.hpp @@ -0,0 +1,40 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "unique_store_remapper.h" + +namespace vespalib::datastore { + +template <typename RefT> +UniqueStoreRemapper<RefT>::UniqueStoreRemapper(EntryRefFilter&& filter) + : _filter(std::move(filter)), + _mapping() +{ +} +template <typename RefT> +UniqueStoreRemapper<RefT>::~UniqueStoreRemapper() = default; + +template <typename RefT> +EntryRef +UniqueStoreRemapper<RefT>::remap(EntryRef ref) const { + RefType internal_ref(ref); + auto &inner_mapping = _mapping[internal_ref.bufferId()]; + assert(internal_ref.offset() < inner_mapping.size()); + EntryRef mapped_ref = inner_mapping[internal_ref.offset()]; + assert(mapped_ref.valid()); + return mapped_ref; +} + +template <typename RefT> +void +UniqueStoreRemapper<RefT>::remap(vespalib::ArrayRef<AtomicEntryRef> refs) const { + for (auto &atomic_ref : refs) { + auto ref = atomic_ref.load_relaxed(); + if (ref.valid() && _filter.has(ref)) { + atomic_ref.store_release(remap(ref)); + } + } +} + +} diff --git a/vespalib/src/vespa/vespalib/util/cpu_usage.cpp b/vespalib/src/vespa/vespalib/util/cpu_usage.cpp index 97dbedad66f..89ba03fdab9 100644 --- a/vespalib/src/vespa/vespalib/util/cpu_usage.cpp +++ b/vespalib/src/vespa/vespalib/util/cpu_usage.cpp @@ -141,6 +141,8 @@ CpuUsage::CpuUsage() { } +CpuUsage::~CpuUsage() = default; + CpuUsage & CpuUsage::self() { diff --git a/vespalib/src/vespa/vespalib/util/cpu_usage.h b/vespalib/src/vespa/vespalib/util/cpu_usage.h index 31309d88f5f..a5687031522 100644 --- a/vespalib/src/vespa/vespalib/util/cpu_usage.h +++ b/vespalib/src/vespa/vespalib/util/cpu_usage.h @@ -166,6 +166,7 @@ private: CpuUsage(const CpuUsage &) = delete; CpuUsage &operator=(CpuUsage &&) = delete; CpuUsage &operator=(const CpuUsage &) = delete; + ~CpuUsage(); static CpuUsage &self(); |