summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-06-22 21:11:57 +0200
committerTor Egge <Tor.Egge@online.no>2023-06-22 21:11:57 +0200
commit7fefea1a7b1bd6d4007a371a7ba1606448aabfec (patch)
tree965957aa3275f8bd131dee71246de18cdb9f46c7 /vespalib
parent207ec83706db045fae8667de1a7558963fd8737e (diff)
Use 64 bytes alignment for large arrays.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/datastore/array_store_dynamic_type_mapper/array_store_dynamic_type_mapper_test.cpp18
-rw-r--r--vespalib/src/vespa/vespalib/datastore/dynamic_array_buffer_type.hpp3
2 files changed, 12 insertions, 9 deletions
diff --git a/vespalib/src/tests/datastore/array_store_dynamic_type_mapper/array_store_dynamic_type_mapper_test.cpp b/vespalib/src/tests/datastore/array_store_dynamic_type_mapper/array_store_dynamic_type_mapper_test.cpp
index 7ead0b97269..c81c679dca0 100644
--- a/vespalib/src/tests/datastore/array_store_dynamic_type_mapper/array_store_dynamic_type_mapper_test.cpp
+++ b/vespalib/src/tests/datastore/array_store_dynamic_type_mapper/array_store_dynamic_type_mapper_test.cpp
@@ -134,16 +134,16 @@ TEST_F(ArrayStoreDynamicTypeMapperCharTest, type_ids_are_selected)
TEST_F(ArrayStoreDynamicTypeMapperCharTest, large_arrays_grows_exponentially)
{
- EXPECT_EQ((std::vector<size_t>{232, 5024, 97100, 1866776}), get_large_array_sizes(4));
+ EXPECT_EQ((std::vector<size_t>{232, 13372, 276860, 5338108}), get_large_array_sizes(4));
}
TEST_F(ArrayStoreDynamicTypeMapperCharTest, avoid_entry_size_overflow)
{
EXPECT_EQ(32, calc_max_buffer_type_id(2.0));
- EXPECT_EQ(410, calc_max_buffer_type_id(1.05));
- EXPECT_EQ(507, calc_max_buffer_type_id(1.04));
- EXPECT_EQ(661, calc_max_buffer_type_id(1.03));
- EXPECT_EQ(968, calc_max_buffer_type_id(1.02));
+ EXPECT_EQ(395, calc_max_buffer_type_id(1.05));
+ EXPECT_EQ(485, calc_max_buffer_type_id(1.04));
+ EXPECT_EQ(626, calc_max_buffer_type_id(1.03));
+ EXPECT_EQ(900, calc_max_buffer_type_id(1.02));
}
using ArrayStoreDynamicTypeMapperInt32Test = TestBase<int32_t>;
@@ -160,10 +160,10 @@ TEST_F(ArrayStoreDynamicTypeMapperInt32Test, array_sizes_are_calculated)
TEST_F(ArrayStoreDynamicTypeMapperInt32Test, avoid_entry_size_overflow)
{
EXPECT_EQ(30, calc_max_buffer_type_id(2.0));
- EXPECT_EQ(395, calc_max_buffer_type_id(1.05));
- EXPECT_EQ(487, calc_max_buffer_type_id(1.04));
- EXPECT_EQ(636, calc_max_buffer_type_id(1.03));
- EXPECT_EQ(930, calc_max_buffer_type_id(1.02));
+ EXPECT_EQ(379, calc_max_buffer_type_id(1.05));
+ EXPECT_EQ(462, calc_max_buffer_type_id(1.04));
+ EXPECT_EQ(596, calc_max_buffer_type_id(1.03));
+ EXPECT_EQ(849, calc_max_buffer_type_id(1.02));
}
GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/vespalib/src/vespa/vespalib/datastore/dynamic_array_buffer_type.hpp b/vespalib/src/vespa/vespalib/datastore/dynamic_array_buffer_type.hpp
index df27e241def..c963712537e 100644
--- a/vespalib/src/vespa/vespalib/datastore/dynamic_array_buffer_type.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/dynamic_array_buffer_type.hpp
@@ -25,6 +25,9 @@ size_t
DynamicArrayBufferType<ElemT>::calc_entry_size(size_t array_size) noexcept
{
auto entry_size = EntryMinAligner::align(sizeof(ElemType) * array_size + sizeof(uint32_t));
+ if (entry_size >= 512) {
+ entry_size = Aligner<64>::align(entry_size);
+ }
return entry_size;
}