diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-15 21:58:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 21:58:05 +0100 |
commit | a929c7ad20c4d4e3087b2b495fea7e1545e72979 (patch) | |
tree | a05616e936625c649a212c8144e3bcece7ff9d47 | |
parent | 0d2b7aef3fddce1d768d096ad973dc95ecc101e9 (diff) | |
parent | 4a98b48751984f0cb80c5bd6ad7924df41a219c5 (diff) |
Merge pull request #26454 from vespa-engine/balder/reduce-buffertype-structure-sizev8.140.13
- GC unused _activeBuffers member.
7 files changed, 31 insertions, 33 deletions
diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index 6699ea82f1f..7eb43faac18 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -6,15 +6,13 @@ #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/attribute/attributememorysavetarget.h> -#include <vespa/searchlib/attribute/multienumattribute.hpp> #include <vespa/searchlib/attribute/multistringattribute.h> -#include <vespa/searchlib/attribute/multivalueattribute.hpp> #include <vespa/searchlib/attribute/predicate_attribute.h> -#include <vespa/searchlib/attribute/singlenumericpostattribute.h> #include <vespa/searchlib/attribute/singlestringattribute.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/test/weighted_type_test_utils.h> #include <vespa/searchlib/util/randomgenerator.h> +#include <vespa/searchcommon/attribute/config.h> #include <vespa/document/fieldvalue/intfieldvalue.h> #include <vespa/document/fieldvalue/stringfieldvalue.h> #include <vespa/document/update/arithmeticvalueupdate.h> @@ -899,7 +897,7 @@ AttributeTest::testSingle() { AttributePtr ptr = createAttribute("sv-int32", Config(BasicType::INT32, CollectionType::SINGLE)); ptr->updateStat(true); - EXPECT_EQ(12288u, ptr->getStatus().getAllocated()); + EXPECT_EQ(4224u, ptr->getStatus().getAllocated()); EXPECT_EQ(0u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testSingle<IntegerAttribute, AttributeVector::largeint_t, int32_t>(ptr, values); @@ -914,7 +912,7 @@ AttributeTest::testSingle() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("sv-post-int32", cfg); ptr->updateStat(true); - EXPECT_EQ(347084u, ptr->getStatus().getAllocated()); + EXPECT_EQ(339020u, ptr->getStatus().getAllocated()); EXPECT_EQ(101852u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testSingle<IntegerAttribute, AttributeVector::largeint_t, int32_t>(ptr, values); @@ -926,7 +924,7 @@ AttributeTest::testSingle() { AttributePtr ptr = createAttribute("sv-float", Config(BasicType::FLOAT, CollectionType::SINGLE)); ptr->updateStat(true); - EXPECT_EQ(12288u, ptr->getStatus().getAllocated()); + EXPECT_EQ(4224u, ptr->getStatus().getAllocated()); EXPECT_EQ(0u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testSingle<FloatingPointAttribute, double, float>(ptr, values); @@ -936,7 +934,7 @@ AttributeTest::testSingle() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("sv-post-float", cfg); ptr->updateStat(true); - EXPECT_EQ(347084u, ptr->getStatus().getAllocated()); + EXPECT_EQ(339020, ptr->getStatus().getAllocated()); EXPECT_EQ(101852u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testSingle<FloatingPointAttribute, double, float>(ptr, values); @@ -949,7 +947,7 @@ AttributeTest::testSingle() { AttributePtr ptr = createAttribute("sv-string", Config(BasicType::STRING, CollectionType::SINGLE)); ptr->updateStat(true); - EXPECT_EQ(133096u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); + EXPECT_EQ(117256u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); EXPECT_EQ(53240u + sizeof_large_string_entry, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testSingle<StringAttribute, string, string>(ptr, values); @@ -959,7 +957,7 @@ AttributeTest::testSingle() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("sv-fs-string", cfg); ptr->updateStat(true); - EXPECT_EQ(361464u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); + EXPECT_EQ(345624u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); EXPECT_EQ(105176u + sizeof_large_string_entry, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testSingle<StringAttribute, string, string>(ptr, values); @@ -1091,8 +1089,8 @@ AttributeTest::testArray() { AttributePtr ptr = createAttribute("a-int32", Config(BasicType::INT32, CollectionType::ARRAY)); ptr->updateStat(true); - EXPECT_EQ(528304u, ptr->getStatus().getAllocated()); - EXPECT_EQ(512576u, ptr->getStatus().getUsed()); + EXPECT_EQ(512056u, ptr->getStatus().getAllocated()); + EXPECT_EQ(504392u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testArray<IntegerAttribute, AttributeVector::largeint_t>(ptr, values); } @@ -1101,8 +1099,8 @@ AttributeTest::testArray() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("flags", cfg); ptr->updateStat(true); - EXPECT_EQ(528304u, ptr->getStatus().getAllocated()); - EXPECT_EQ(512576u, ptr->getStatus().getUsed()); + EXPECT_EQ(512056u, ptr->getStatus().getAllocated()); + EXPECT_EQ(504392u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testArray<IntegerAttribute, AttributeVector::largeint_t>(ptr, values); } @@ -1111,8 +1109,8 @@ AttributeTest::testArray() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("a-fs-int32", cfg); ptr->updateStat(true); - EXPECT_EQ(885036u, ptr->getStatus().getAllocated()); - EXPECT_EQ(614448u, ptr->getStatus().getUsed()); + EXPECT_EQ(868788u, ptr->getStatus().getAllocated()); + EXPECT_EQ(606264u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testArray<IntegerAttribute, AttributeVector::largeint_t>(ptr, values); } @@ -1130,8 +1128,8 @@ AttributeTest::testArray() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("a-fs-float", cfg); ptr->updateStat(true); - EXPECT_EQ(885036u, ptr->getStatus().getAllocated()); - EXPECT_EQ(614448u, ptr->getStatus().getUsed()); + EXPECT_EQ(868788u, ptr->getStatus().getAllocated()); + EXPECT_EQ(606264u, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testArray<FloatingPointAttribute, double>(ptr, values); } @@ -1142,8 +1140,8 @@ AttributeTest::testArray() { AttributePtr ptr = createAttribute("a-string", Config(BasicType::STRING, CollectionType::ARRAY)); ptr->updateStat(true); - EXPECT_EQ(649112u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); - EXPECT_EQ(565816u + sizeof_large_string_entry, ptr->getStatus().getUsed()); + EXPECT_EQ(625088u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); + EXPECT_EQ(557632u + sizeof_large_string_entry, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testArray<StringAttribute, string>(ptr, values); } @@ -1152,8 +1150,8 @@ AttributeTest::testArray() cfg.setFastSearch(true); AttributePtr ptr = createAttribute("afs-string", cfg); ptr->updateStat(true); - EXPECT_EQ(899416u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); - EXPECT_EQ(617772u + sizeof_large_string_entry, ptr->getStatus().getUsed()); + EXPECT_EQ(875392u + sizeof_large_string_entry, ptr->getStatus().getAllocated()); + EXPECT_EQ(609588u + sizeof_large_string_entry, ptr->getStatus().getUsed()); addDocs(ptr, numDocs); testArray<StringAttribute, string>(ptr, values); } diff --git a/searchlib/src/tests/attribute/changevector/changevector_test.cpp b/searchlib/src/tests/attribute/changevector/changevector_test.cpp index c37d233217b..7820638ab3c 100644 --- a/searchlib/src/tests/attribute/changevector/changevector_test.cpp +++ b/searchlib/src/tests/attribute/changevector/changevector_test.cpp @@ -91,10 +91,10 @@ TEST("require that inserting empty vector does not affect the vector.") { TEST("require that we have control over buffer construction size") { CV a; EXPECT_EQUAL(0u, a.size()); - EXPECT_EQUAL(256u, a.capacity()); + EXPECT_EQUAL(4u, a.capacity()); a.clear(); EXPECT_EQUAL(0u, a.size()); - EXPECT_EQUAL(256u, a.capacity()); + EXPECT_EQUAL(4u, a.capacity()); } TEST("require that buffer can grow some") { diff --git a/searchlib/src/vespa/searchlib/attribute/changevector.hpp b/searchlib/src/vespa/searchlib/attribute/changevector.hpp index a81c14aa85c..08e914d4a1a 100644 --- a/searchlib/src/vespa/searchlib/attribute/changevector.hpp +++ b/searchlib/src/vespa/searchlib/attribute/changevector.hpp @@ -15,6 +15,7 @@ namespace { // This number is selected to be large enough to hold bursts between commits constexpr size_t NUM_ELEMS_TO_RESERVE = 200; +constexpr size_t NUM_ELEMS_TO_RESERVE_INITIAL = 4; } @@ -22,7 +23,7 @@ template <typename T> ChangeVectorT<T>::ChangeVectorT() : _v() { - _v.reserve(roundUp2inN<T>(NUM_ELEMS_TO_RESERVE)); + _v.reserve(roundUp2inN<T>(NUM_ELEMS_TO_RESERVE_INITIAL)); } template <typename T> 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 8ee9eaeb4f7..ccc3ab88c31 100644 --- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp +++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp @@ -210,12 +210,12 @@ INSTANTIATE_TEST_SUITE_P(NumberStoreFreeListsDisabledMultiTest, TEST_P(NumberStoreTest, control_static_sizes) { static constexpr size_t sizeof_deque = vespalib::datastore::DataStoreBase::sizeof_entry_ref_hold_list_deque; - EXPECT_EQ(416u + sizeof_deque, sizeof(store)); + EXPECT_EQ(408u + sizeof_deque, sizeof(store)); EXPECT_EQ(240u + sizeof_deque, sizeof(NumberStoreTest::ArrayStoreType::DataStoreType)); - EXPECT_EQ(112u, sizeof(NumberStoreTest::ArrayStoreType::SmallBufferType)); + EXPECT_EQ(104u, sizeof(NumberStoreTest::ArrayStoreType::SmallBufferType)); MemoryUsage usage = store.getMemoryUsage(); - EXPECT_EQ(202144u, usage.allocatedBytes()); - EXPECT_EQ(197776u, usage.usedBytes()); + EXPECT_EQ(202120u, usage.allocatedBytes()); + EXPECT_EQ(197752u, usage.usedBytes()); } TEST_P(NumberStoreTest, add_and_get_small_arrays_of_trivial_type) diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp index 7121bf5ce11..df347267c7e 100644 --- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp +++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp @@ -665,7 +665,7 @@ TEST(DataStoreTest, can_reuse_active_buffer_as_primary_buffer) } TEST(DataStoreTest, control_static_sizes) { - EXPECT_EQ(96, sizeof(BufferTypeBase)); + EXPECT_EQ(88, sizeof(BufferTypeBase)); EXPECT_EQ(24, sizeof(FreeList)); EXPECT_EQ(56, sizeof(BufferFreeList)); EXPECT_EQ(1, sizeof(BufferState::State)); diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp index 0de44eb373e..5ccf9a8908c 100644 --- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp +++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp @@ -471,7 +471,7 @@ TEST_F(DoubleTest, nan_is_handled) TEST_F(DoubleTest, control_memory_usage) { static constexpr size_t sizeof_deque = vespalib::datastore::DataStoreBase::sizeof_entry_ref_hold_list_deque; - EXPECT_EQ(376u + sizeof_deque, sizeof(store)); + EXPECT_EQ(368u + sizeof_deque, sizeof(store)); EXPECT_EQ(144u, sizeof(BufferState)); EXPECT_EQ(28740u, store.get_values_memory_usage().allocatedBytes()); EXPECT_EQ(24804u, store.get_values_memory_usage().usedBytes()); diff --git a/vespalib/src/vespa/vespalib/datastore/buffer_type.h b/vespalib/src/vespa/vespalib/datastore/buffer_type.h index 53436df432f..bedbb2c984e 100644 --- a/vespalib/src/vespa/vespalib/datastore/buffer_type.h +++ b/vespalib/src/vespa/vespalib/datastore/buffer_type.h @@ -85,7 +85,7 @@ protected: ElemCount dead_elems; BufferCounts() : used_elems(0), dead_elems(0) {} BufferCounts(ElemCount used_elems_in, ElemCount dead_elems_in) - : used_elems(used_elems_in), dead_elems(dead_elems_in) + : used_elems(used_elems_in), dead_elems(dead_elems_in) {} }; @@ -99,7 +99,7 @@ protected: const std::atomic<ElemCount>* dead_ptr; Element() noexcept : used_ptr(nullptr), dead_ptr(nullptr) {} Element(const std::atomic<ElemCount>* used_ptr_in, const std::atomic<ElemCount>* dead_ptr_in) noexcept - : used_ptr(used_ptr_in), dead_ptr(dead_ptr_in) + : used_ptr(used_ptr_in), dead_ptr(dead_ptr_in) {} }; std::vector<Element> _counts; @@ -119,7 +119,6 @@ protected: // Number of arrays needed before allocating a new buffer instead of just resizing the first one uint32_t _numArraysForNewBuffer; float _allocGrowFactor; - uint32_t _activeBuffers; uint32_t _holdBuffers; size_t _holdUsedElems; // Number of used elements in all held buffers for this type. AggregatedBufferCounts _aggr_counts; |