diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-03-23 12:55:13 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-03-23 12:55:13 +0100 |
commit | 7d3b2d771160864a60557c2e4e4660f417d4fbab (patch) | |
tree | a482a57d76f6a5d2114f2f9e4369b9e88dfbf305 /searchlib | |
parent | d2533769f355b0475c4ca39ad77f5c70140d070b (diff) |
Report address space usage for raw attribute.
Diffstat (limited to 'searchlib')
6 files changed, 28 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/raw_attribute/raw_attribute_test.cpp b/searchlib/src/tests/attribute/raw_attribute/raw_attribute_test.cpp index 2278b49e31b..c4da5036b36 100644 --- a/searchlib/src/tests/attribute/raw_attribute/raw_attribute_test.cpp +++ b/searchlib/src/tests/attribute/raw_attribute/raw_attribute_test.cpp @@ -1,12 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/attribute/single_raw_attribute.h> +#include <vespa/searchlib/attribute/address_space_components.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/vespalib/gtest/gtest.h> #include <filesystem> #include <memory> +using search::AddressSpaceComponents; +using search::AddressSpaceUsage; using search::AttributeFactory; using search::AttributeVector; using search::attribute::BasicType; @@ -136,4 +139,18 @@ TEST_F(RawAttributeTest, save_and_load) remove_saved_attr(); } +TEST_F(RawAttributeTest, address_space_usage_is_reported) +{ + auto& raw_store = AddressSpaceComponents::raw_store; + _attr->addDocs(1); + _attr->commit(); + AddressSpaceUsage usage = _attr->getAddressSpaceUsage(); + const auto& all = usage.get_all(); + EXPECT_EQ(1u, all.size()); + EXPECT_EQ(1u, all.count(raw_store)); + EXPECT_EQ(1, all.at(raw_store).used()); + _raw->set_raw(1, as_vector("foo")); + EXPECT_EQ(2, _attr->getAddressSpaceUsage().get_all().at(raw_store).used()); +} + GTEST_MAIN_RUN_ALL_TESTS() diff --git a/searchlib/src/vespa/searchlib/attribute/address_space_components.cpp b/searchlib/src/vespa/searchlib/attribute/address_space_components.cpp index 75c198f71e2..70e0b8b8d0b 100644 --- a/searchlib/src/vespa/searchlib/attribute/address_space_components.cpp +++ b/searchlib/src/vespa/searchlib/attribute/address_space_components.cpp @@ -17,6 +17,7 @@ AddressSpace AddressSpaceComponents::default_multi_value_usage() { const vespalib::string AddressSpaceComponents::enum_store = "enum-store"; const vespalib::string AddressSpaceComponents::multi_value = "multi-value"; +const vespalib::string AddressSpaceComponents::raw_store = "raw-store"; const vespalib::string AddressSpaceComponents::tensor_store = "tensor-store"; const vespalib::string AddressSpaceComponents::shared_string_repo = "shared-string-repo"; const vespalib::string AddressSpaceComponents::hnsw_levels_store = "hnsw-levels-store"; diff --git a/searchlib/src/vespa/searchlib/attribute/address_space_components.h b/searchlib/src/vespa/searchlib/attribute/address_space_components.h index 20302a51f0d..10425318e73 100644 --- a/searchlib/src/vespa/searchlib/attribute/address_space_components.h +++ b/searchlib/src/vespa/searchlib/attribute/address_space_components.h @@ -16,6 +16,7 @@ public: static vespalib::AddressSpace default_multi_value_usage(); static const vespalib::string enum_store; static const vespalib::string multi_value; + static const vespalib::string raw_store; static const vespalib::string tensor_store; static const vespalib::string shared_string_repo; static const vespalib::string hnsw_levels_store; diff --git a/searchlib/src/vespa/searchlib/attribute/raw_buffer_store.h b/searchlib/src/vespa/searchlib/attribute/raw_buffer_store.h index 2731157b13c..bc3c189b329 100644 --- a/searchlib/src/vespa/searchlib/attribute/raw_buffer_store.h +++ b/searchlib/src/vespa/searchlib/attribute/raw_buffer_store.h @@ -26,6 +26,7 @@ public: vespalib::ConstArrayRef<char> get(EntryRef ref) const; void remove(EntryRef ref) { _array_store.remove(ref); } vespalib::MemoryUsage update_stat(const vespalib::datastore::CompactionStrategy& compaction_strategy) { return _array_store.update_stat(compaction_strategy); } + vespalib::AddressSpace get_address_space_usage() const { return _array_store.addressSpaceUsage(); } bool consider_compact() const noexcept { return _array_store.consider_compact(); } std::unique_ptr<vespalib::datastore::ICompactionContext> start_compact(const vespalib::datastore::CompactionStrategy& compaction_strategy); void reclaim_memory(generation_t oldest_used_gen) { _array_store.reclaim_memory(oldest_used_gen); } diff --git a/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.cpp index f3be30b44d1..adaf8688db5 100644 --- a/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.cpp @@ -4,6 +4,7 @@ #include "single_raw_attribute_loader.h" #include "single_raw_attribute_saver.h" #include <vespa/searchcommon/attribute/config.h> +#include <vespa/searchlib/attribute/address_space_components.h> #include <vespa/vespalib/datastore/array_store.hpp> using vespalib::alloc::MemoryAllocator; @@ -162,4 +163,10 @@ SingleRawAttribute::isUndefined(DocId docid) const return raw.empty(); } +void +SingleRawAttribute::populate_address_space_usage(AddressSpaceUsage& usage) const +{ + usage.set(AddressSpaceComponents::raw_store, _raw_store.get_address_space_usage()); +} + } diff --git a/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.h b/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.h index 681cb0397d2..74638821466 100644 --- a/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/single_raw_attribute.h @@ -24,6 +24,7 @@ class SingleRawAttribute : public RawAttribute EntryRef acquire_entry_ref(DocId docid) const noexcept { return _ref_vector.acquire_elem_ref(docid).load_acquire(); } bool onLoad(vespalib::Executor *executor) override; std::unique_ptr<AttributeSaver> onInitSave(vespalib::stringref fileName) override; + void populate_address_space_usage(AddressSpaceUsage& usage) const override; public: SingleRawAttribute(const vespalib::string& name, const Config& config); ~SingleRawAttribute() override; |