aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-03-15 16:45:23 +0100
committerGitHub <noreply@github.com>2019-03-15 16:45:23 +0100
commitdfc78d6e35f158e834c843bfc782a6d88143cc76 (patch)
tree02dd82d5b88285886c7f8a3bcf5438c432744d59 /searchlib
parent29000f74690a5f330d6e1402b5e03d180ad1611c (diff)
parent1a7ea8b992e88b78af652a81b1a0f96f15b067fd (diff)
Merge pull request #8801 from vespa-engine/geirst/renaming-in-datastore-buffer-type
Rename "cluster" concept in buffer type to "array".
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp6
-rw-r--r--searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp8
-rw-r--r--searchlib/src/tests/datastore/array_store/array_store_test.cpp14
-rw-r--r--searchlib/src/tests/datastore/buffer_type/buffer_type_test.cpp78
-rw-r--r--searchlib/src/tests/datastore/datastore/datastore_test.cpp42
-rw-r--r--searchlib/src/tests/tensor/dense_tensor_store/dense_tensor_store_test.cpp26
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstorebase.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreenodestore.h8
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreenodestore.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreestore.h2
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreestore.hpp18
-rw-r--r--searchlib/src/vespa/searchlib/datastore/allocator.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/datastore/array_store.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/datastore/buffer_type.cpp72
-rw-r--r--searchlib/src/vespa/searchlib/datastore/buffer_type.h87
-rw-r--r--searchlib/src/vespa/searchlib/datastore/bufferstate.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/datastore/bufferstate.h13
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastore.h19
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastore.hpp17
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastorebase.cpp121
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastorebase.h44
-rw-r--r--searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp6
-rw-r--r--searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp8
-rw-r--r--searchlib/src/vespa/searchlib/datastore/unique_store.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/wordstore.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h6
-rw-r--r--searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp4
33 files changed, 333 insertions, 342 deletions
diff --git a/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp b/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp
index ce9e6bc737e..0ea6a029e84 100644
--- a/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp
+++ b/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp
@@ -174,8 +174,8 @@ TEST_F("Test that no compaction of int8 array attribute increases address space
f.populate(range1, 1000);
f.hammer(range2, 101);
AddressSpace afterSpace = f.getMultiValueAddressSpaceUsage("after");
- // 100 * 1000 dead clusters due to new values for docids
- // 1 reserved cluster accounted as dead
+ // 100 * 1000 dead arrays due to new values for docids
+ // 1 reserved array accounted as dead
EXPECT_EQUAL(100001u, afterSpace.dead());
}
@@ -186,7 +186,7 @@ TEST_F("Test that compaction of int8 array attribute limits address space usage"
f.populate(range1, 1000);
f.hammer(range2, 101);
AddressSpace afterSpace = f.getMultiValueAddressSpaceUsage("after");
- // DEAD_CLUSTERS_SLACK in multi value mapping is is 64k
+ // DEAD_ARRAYS_SLACK in multi value mapping is is 64k
EXPECT_GREATER(65536u, afterSpace.dead());
}
diff --git a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp
index a6fa7d6543d..8c0cd95eecb 100644
--- a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp
+++ b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp
@@ -80,9 +80,9 @@ public:
_attr(_mvMapping)
{
}
- Fixture(uint32_t maxSmallArraySize, size_t minClusters, size_t maxClusters, size_t numClustersForNewBuffer)
+ Fixture(uint32_t maxSmallArraySize, size_t minArrays, size_t maxArrays, size_t numArraysForNewBuffer)
: _mvMapping(ArrayStoreConfig(maxSmallArraySize,
- ArrayStoreConfig::AllocSpec(minClusters, maxClusters, numClustersForNewBuffer,
+ ArrayStoreConfig::AllocSpec(minArrays, maxArrays, numArraysForNewBuffer,
ALLOC_GROW_FACTOR))),
_attr(_mvMapping)
{
@@ -154,8 +154,8 @@ public:
_rnd.srand48(32);
}
- IntFixture(uint32_t maxSmallArraySize, size_t minClusters, size_t maxClusters, size_t numClustersForNewBuffer)
- : Fixture<int>(maxSmallArraySize, minClusters, maxClusters, numClustersForNewBuffer),
+ IntFixture(uint32_t maxSmallArraySize, size_t minArrays, size_t maxArrays, size_t numArraysForNewBuffer)
+ : Fixture<int>(maxSmallArraySize, minArrays, maxArrays, numArraysForNewBuffer),
_rnd(),
_refMapping(),
_maxSmallArraySize(maxSmallArraySize)
diff --git a/searchlib/src/tests/datastore/array_store/array_store_test.cpp b/searchlib/src/tests/datastore/array_store/array_store_test.cpp
index f5d76852888..b99d74cf475 100644
--- a/searchlib/src/tests/datastore/array_store/array_store_test.cpp
+++ b/searchlib/src/tests/datastore/array_store/array_store_test.cpp
@@ -321,21 +321,21 @@ TEST_F("require that used, onHold and dead memory usage is tracked for large arr
dead(f.largeArraySize())));
}
-TEST_F("require that address space usage is ratio between used clusters and number of possible clusters", NumberFixture(3))
+TEST_F("require that address space usage is ratio between used arrays and number of possible arrays", NumberFixture(3))
{
f.add({2,2});
f.add({3,3,3});
- // 1 cluster is reserved (buffer 0, offset 0).
+ // 1 array is reserved (buffer 0, offset 0).
EXPECT_EQUAL(3u, f.store.addressSpaceUsage().used());
EXPECT_EQUAL(1u, f.store.addressSpaceUsage().dead());
size_t fourgig = (1ull << 32);
/*
- * Expected limit is sum of allocated clusters for active buffers and
- * potentially allocated clusters for free buffers. If all buffers were
+ * Expected limit is sum of allocated arrays for active buffers and
+ * potentially allocated arrays for free buffers. If all buffers were
* free then the limit would be 4 Gi.
- * Then we subtract clusters for 4 buffers that are not free (arraySize=1,2,3 + largeArray),
- * and add their actual number of allocated clusters (16 clusters per buffer).
- * Note: arraySize=3 has 21 clusters as allocated buffer is rounded up to power of 2:
+ * Then we subtract arrays for 4 buffers that are not free (arraySize=1,2,3 + largeArray),
+ * and add their actual number of allocated arrays (16 arrays per buffer).
+ * Note: arraySize=3 has 21 arrays as allocated buffer is rounded up to power of 2:
* 16 * 3 * sizeof(int) = 192 -> 256.
* allocated elements = 256 / sizeof(int) = 64.
* limit = 64 / 3 = 21.
diff --git a/searchlib/src/tests/datastore/buffer_type/buffer_type_test.cpp b/searchlib/src/tests/datastore/buffer_type/buffer_type_test.cpp
index 1477a7281e6..2ea615bea08 100644
--- a/searchlib/src/tests/datastore/buffer_type/buffer_type_test.cpp
+++ b/searchlib/src/tests/datastore/buffer_type/buffer_type_test.cpp
@@ -6,26 +6,26 @@
using namespace search::datastore;
using IntBufferType = BufferType<int>;
-constexpr uint32_t CLUSTER_SIZE(4);
-constexpr uint32_t MAX_CLUSTERS(128);
-constexpr uint32_t NUM_CLUSTERS_FOR_NEW_BUFFER(0);
+constexpr uint32_t ARRAYS_SIZE(4);
+constexpr uint32_t MAX_ARRAYS(128);
+constexpr uint32_t NUM_ARRAYS_FOR_NEW_BUFFER(0);
struct Setup {
- uint32_t _minClusters;
+ uint32_t _minArrays;
size_t _usedElems;
size_t _neededElems;
uint32_t _bufferId;
float _allocGrowFactor;
bool _resizing;
Setup()
- : _minClusters(0),
+ : _minArrays(0),
_usedElems(0),
_neededElems(0),
_bufferId(1),
_allocGrowFactor(0.5),
_resizing(false)
{}
- Setup &minClusters(uint32_t value) { _minClusters = value; return *this; }
+ Setup &minArrays(uint32_t value) { _minArrays = value; return *this; }
Setup &used(size_t value) { _usedElems = value; return *this; }
Setup &needed(size_t value) { _neededElems = value; return *this; }
Setup &bufferId(uint32_t value) { _bufferId = value; return *this; }
@@ -39,7 +39,7 @@ struct Fixture {
int buffer;
Fixture(const Setup &setup_)
: setup(setup_),
- bufferType(CLUSTER_SIZE, setup._minClusters, MAX_CLUSTERS, NUM_CLUSTERS_FOR_NEW_BUFFER, setup._allocGrowFactor),
+ bufferType(ARRAYS_SIZE, setup._minArrays, MAX_ARRAYS, NUM_ARRAYS_FOR_NEW_BUFFER, setup._allocGrowFactor),
deadElems(0),
buffer(0)
{}
@@ -50,67 +50,67 @@ struct Fixture {
void onActive() {
bufferType.onActive(setup._bufferId, &setup._usedElems, deadElems, &buffer);
}
- size_t clustersToAlloc() {
- return bufferType.calcClustersToAlloc(setup._bufferId, setup._neededElems, setup._resizing);
+ size_t arraysToAlloc() {
+ return bufferType.calcArraysToAlloc(setup._bufferId, setup._neededElems, setup._resizing);
}
};
void
-assertClustersToAlloc(size_t exp, const Setup &setup)
+assertArraysToAlloc(size_t exp, const Setup &setup)
{
Fixture f(setup);
f.onActive();
- EXPECT_EQUAL(exp, f.clustersToAlloc());
+ EXPECT_EQUAL(exp, f.arraysToAlloc());
}
-TEST("require that complete clusters are allocated")
+TEST("require that complete arrays are allocated")
{
- TEST_DO(assertClustersToAlloc(1, Setup().needed(1)));
- TEST_DO(assertClustersToAlloc(1, Setup().needed(2)));
- TEST_DO(assertClustersToAlloc(1, Setup().needed(3)));
- TEST_DO(assertClustersToAlloc(1, Setup().needed(4)));
- TEST_DO(assertClustersToAlloc(2, Setup().needed(5)));
+ TEST_DO(assertArraysToAlloc(1, Setup().needed(1)));
+ TEST_DO(assertArraysToAlloc(1, Setup().needed(2)));
+ TEST_DO(assertArraysToAlloc(1, Setup().needed(3)));
+ TEST_DO(assertArraysToAlloc(1, Setup().needed(4)));
+ TEST_DO(assertArraysToAlloc(2, Setup().needed(5)));
}
TEST("require that reserved elements are taken into account when not resizing")
{
- TEST_DO(assertClustersToAlloc(2, Setup().needed(1).bufferId(0)));
- TEST_DO(assertClustersToAlloc(2, Setup().needed(4).bufferId(0)));
- TEST_DO(assertClustersToAlloc(3, Setup().needed(5).bufferId(0)));
+ TEST_DO(assertArraysToAlloc(2, Setup().needed(1).bufferId(0)));
+ TEST_DO(assertArraysToAlloc(2, Setup().needed(4).bufferId(0)));
+ TEST_DO(assertArraysToAlloc(3, Setup().needed(5).bufferId(0)));
}
-TEST("require that clusters to alloc is based on currently used elements (no resizing)")
+TEST("require that arrays to alloc is based on currently used elements (no resizing)")
{
- TEST_DO(assertClustersToAlloc(2, Setup().used(4 * 4).needed(4)));
- TEST_DO(assertClustersToAlloc(4, Setup().used(8 * 4).needed(4)));
+ TEST_DO(assertArraysToAlloc(2, Setup().used(4 * 4).needed(4)));
+ TEST_DO(assertArraysToAlloc(4, Setup().used(8 * 4).needed(4)));
}
-TEST("require that clusters to alloc is based on currently used elements (with resizing)")
+TEST("require that arrays to alloc is based on currently used elements (with resizing)")
{
- TEST_DO(assertClustersToAlloc(4 + 2, Setup().used(4 * 4).needed(4).resizing(true)));
- TEST_DO(assertClustersToAlloc(8 + 4, Setup().used(8 * 4).needed(4).resizing(true)));
- TEST_DO(assertClustersToAlloc(4 + 3, Setup().used(4 * 4).needed(3 * 4).resizing(true)));
+ TEST_DO(assertArraysToAlloc(4 + 2, Setup().used(4 * 4).needed(4).resizing(true)));
+ TEST_DO(assertArraysToAlloc(8 + 4, Setup().used(8 * 4).needed(4).resizing(true)));
+ TEST_DO(assertArraysToAlloc(4 + 3, Setup().used(4 * 4).needed(3 * 4).resizing(true)));
}
-TEST("require that clusters to alloc always contain elements needed")
+TEST("require that arrays to alloc always contain elements needed")
{
- TEST_DO(assertClustersToAlloc(2, Setup().used(4 * 4).needed(2 * 4)));
- TEST_DO(assertClustersToAlloc(3, Setup().used(4 * 4).needed(3 * 4)));
- TEST_DO(assertClustersToAlloc(4, Setup().used(4 * 4).needed(4 * 4)));
+ TEST_DO(assertArraysToAlloc(2, Setup().used(4 * 4).needed(2 * 4)));
+ TEST_DO(assertArraysToAlloc(3, Setup().used(4 * 4).needed(3 * 4)));
+ TEST_DO(assertArraysToAlloc(4, Setup().used(4 * 4).needed(4 * 4)));
}
-TEST("require that clusters to alloc is capped to max clusters")
+TEST("require that arrays to alloc is capped to max arrays")
{
- TEST_DO(assertClustersToAlloc(127, Setup().used(254 * 4).needed(4)));
- TEST_DO(assertClustersToAlloc(128, Setup().used(256 * 4).needed(4)));
- TEST_DO(assertClustersToAlloc(128, Setup().used(258 * 4).needed(8)));
+ TEST_DO(assertArraysToAlloc(127, Setup().used(254 * 4).needed(4)));
+ TEST_DO(assertArraysToAlloc(128, Setup().used(256 * 4).needed(4)));
+ TEST_DO(assertArraysToAlloc(128, Setup().used(258 * 4).needed(8)));
}
-TEST("require that clusters to alloc is capped to min clusters")
+TEST("require that arrays to alloc is capped to min arrays")
{
- TEST_DO(assertClustersToAlloc(16, Setup().used(30 * 4).needed(4).minClusters(16)));
- TEST_DO(assertClustersToAlloc(16, Setup().used(32 * 4).needed(4).minClusters(16)));
- TEST_DO(assertClustersToAlloc(17, Setup().used(34 * 4).needed(4).minClusters(16)));
+ TEST_DO(assertArraysToAlloc(16, Setup().used(30 * 4).needed(4).minArrays(16)));
+ TEST_DO(assertArraysToAlloc(16, Setup().used(32 * 4).needed(4).minArrays(16)));
+ TEST_DO(assertArraysToAlloc(17, Setup().used(34 * 4).needed(4).minArrays(16)));
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchlib/src/tests/datastore/datastore/datastore_test.cpp b/searchlib/src/tests/datastore/datastore/datastore_test.cpp
index aa26afa3077..c364bc2b0e3 100644
--- a/searchlib/src/tests/datastore/datastore/datastore_test.cpp
+++ b/searchlib/src/tests/datastore/datastore/datastore_test.cpp
@@ -67,7 +67,7 @@ public:
using GrowthStats = std::vector<int>;
constexpr float ALLOC_GROW_FACTOR = 0.4;
-constexpr size_t HUGE_PAGE_CLUSTER_SIZE = (MemoryAllocator::HUGEPAGE_SIZE / sizeof(int));
+constexpr size_t HUGE_PAGE_ARRAY_SIZE = (MemoryAllocator::HUGEPAGE_SIZE / sizeof(int));
template <typename DataType, typename RefType>
class GrowStore
@@ -78,10 +78,10 @@ class GrowStore
BufferType<DataType> _type;
uint32_t _typeId;
public:
- GrowStore(size_t clusterSize, size_t minClusters, size_t maxClusters, size_t numClustersForNewBuffer)
+ GrowStore(size_t arraySize, size_t minArrays, size_t maxArrays, size_t numArraysForNewBuffer)
: _store(),
- _firstType(1, 1, maxClusters, 0, ALLOC_GROW_FACTOR),
- _type(clusterSize, minClusters, maxClusters, numClustersForNewBuffer, ALLOC_GROW_FACTOR),
+ _firstType(1, 1, maxArrays, 0, ALLOC_GROW_FACTOR),
+ _type(arraySize, minArrays, maxArrays, numArraysForNewBuffer, ALLOC_GROW_FACTOR),
_typeId(0)
{
(void) _store.addType(&_firstType);
@@ -97,9 +97,9 @@ public:
GrowthStats sizes;
int prevBufferId = -1;
while (sizes.size() < bufs) {
- RefType iRef = (_type.getClusterSize() == 1) ?
+ RefType iRef = (_type.getArraySize() == 1) ?
(_store.template allocator<DataType>(_typeId).alloc().ref) :
- (_store.template allocator<DataType>(_typeId).allocArray(_type.getClusterSize()).ref);
+ (_store.template allocator<DataType>(_typeId).allocArray(_type.getArraySize()).ref);
int bufferId = iRef.bufferId();
if (bufferId != prevBufferId) {
if (prevBufferId >= 0) {
@@ -505,11 +505,11 @@ namespace {
void assertGrowStats(GrowthStats expSizes,
GrowthStats expFirstBufSizes,
size_t expInitMemUsage,
- size_t minClusters, size_t numClustersForNewBuffer, size_t maxClusters = 128)
+ size_t minArrays, size_t numArraysForNewBuffer, size_t maxArrays = 128)
{
- EXPECT_EQ(expSizes, IntGrowStore(1, minClusters, maxClusters, numClustersForNewBuffer).getGrowthStats(expSizes.size()));
- EXPECT_EQ(expFirstBufSizes, IntGrowStore(1, minClusters, maxClusters, numClustersForNewBuffer).getFirstBufGrowStats());
- EXPECT_EQ(expInitMemUsage, IntGrowStore(1, minClusters, maxClusters, numClustersForNewBuffer).getMemoryUsage().allocatedBytes());
+ EXPECT_EQ(expSizes, IntGrowStore(1, minArrays, maxArrays, numArraysForNewBuffer).getGrowthStats(expSizes.size()));
+ EXPECT_EQ(expFirstBufSizes, IntGrowStore(1, minArrays, maxArrays, numArraysForNewBuffer).getFirstBufGrowStats());
+ EXPECT_EQ(expInitMemUsage, IntGrowStore(1, minArrays, maxArrays, numArraysForNewBuffer).getMemoryUsage().allocatedBytes());
}
}
@@ -536,10 +536,10 @@ TEST(DataStoreTest, require_that_buffer_growth_works)
{ 0, 1 }, 4, 0, 0);
// Buffers with sizes larger than the huge page size of the mmap allocator.
- ASSERT_EQ(524288u, HUGE_PAGE_CLUSTER_SIZE);
+ ASSERT_EQ(524288u, HUGE_PAGE_ARRAY_SIZE);
assertGrowStats({ 262144, 262144, 262144, 524288, 524288, 524288 * 2, 524288 * 3, 524288 * 4, 524288 * 5, 524288 * 5 },
{ 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144 },
- 4, 0, HUGE_PAGE_CLUSTER_SIZE / 2, HUGE_PAGE_CLUSTER_SIZE * 5);
+ 4, 0, HUGE_PAGE_ARRAY_SIZE / 2, HUGE_PAGE_ARRAY_SIZE * 5);
}
using RefType15 = EntryRefT<15>; // offsetSize=32768
@@ -547,12 +547,12 @@ using RefType15 = EntryRefT<15>; // offsetSize=32768
namespace {
template <typename DataType>
-void assertGrowStats(GrowthStats expSizes, uint32_t clusterSize)
+void assertGrowStats(GrowthStats expSizes, uint32_t arraySize)
{
- uint32_t minClusters = 2048;
- uint32_t maxClusters = RefType15::offsetSize();
- uint32_t numClustersForNewBuffer = 2048;
- GrowStore<DataType, RefType15> store(clusterSize, minClusters, maxClusters, numClustersForNewBuffer);
+ uint32_t minArrays = 2048;
+ uint32_t maxArrays = RefType15::offsetSize();
+ uint32_t numArraysForNewBuffer = 2048;
+ GrowStore<DataType, RefType15> store(arraySize, minArrays, maxArrays, numArraysForNewBuffer);
EXPECT_EQ(expSizes, store.getGrowthStats(expSizes.size()));
}
@@ -562,14 +562,14 @@ TEST(DataStoreTest, require_that_offset_in_EntryRefT_is_within_bounds_when_alloc
{
/*
* When allocating new memory buffers for the data store the following happens (ref. calcAllocation() in bufferstate.cpp):
- * 1) Calculate how many clusters to alloc.
+ * 1) Calculate how many arrays to alloc.
* In this case we alloc a minimum of 2048 and a maximum of 32768.
- * 2) Calculate how many bytes to alloc: clustersToAlloc * clusterSize * elementSize.
- * In this case elementSize is (1 or 4) and clusterSize varies (3, 5, 7).
+ * 2) Calculate how many bytes to alloc: arraysToAlloc * arraySize * elementSize.
+ * In this case elementSize is (1 or 4) and arraySize varies (3, 5, 7).
* 3) Round up bytes to alloc to match the underlying allocator (power of 2 if less than huge page size):
* After this we might end up with more bytes than the offset in EntryRef can handle. In this case this is 32768.
* 4) Cap bytes to alloc to the max offset EntryRef can handle.
- * The max bytes to alloc is: maxClusters * clusterSize * elementSize.
+ * The max bytes to alloc is: maxArrays * arraySize * elementSize.
*/
assertGrowStats<uint8_t>({8192,8192,8192,16384,16384,32768,65536,65536,98304,98304,98304,98304}, 3);
assertGrowStats<uint8_t>({16384,16384,16384,32768,32768,65536,131072,131072,163840,163840,163840,163840}, 5);
diff --git a/searchlib/src/tests/tensor/dense_tensor_store/dense_tensor_store_test.cpp b/searchlib/src/tests/tensor/dense_tensor_store/dense_tensor_store_test.cpp
index ab43e19251a..9f47dede46a 100644
--- a/searchlib/src/tests/tensor/dense_tensor_store/dense_tensor_store_test.cpp
+++ b/searchlib/src/tests/tensor/dense_tensor_store/dense_tensor_store_test.cpp
@@ -112,23 +112,23 @@ TEST_F("require that empty 3d tensor has size 1 in un-bound dimensions", Fixture
}
void
-assertClusterSize(const vespalib::string &tensorType, uint32_t expClusterSize) {
+assertArraySize(const vespalib::string &tensorType, uint32_t expArraySize) {
Fixture f(tensorType);
- EXPECT_EQUAL(expClusterSize, f.store.getClusterSize());
+ EXPECT_EQUAL(expArraySize, f.store.getArraySize());
}
-TEST("require that cluster size is calculated correctly")
+TEST("require that array size is calculated correctly")
{
- TEST_DO(assertClusterSize("tensor(x[1])", 32));
- TEST_DO(assertClusterSize("tensor(x[10])", 96));
- TEST_DO(assertClusterSize("tensor(x[3])", 32));
- TEST_DO(assertClusterSize("tensor(x[3],y[])", 32));
- TEST_DO(assertClusterSize("tensor(x[3],y[],z[])", 32));
- TEST_DO(assertClusterSize("tensor(x[3],y[],z[],z2[])", 64));
- TEST_DO(assertClusterSize("tensor(x[10],y[10])", 800));
- TEST_DO(assertClusterSize("tensor(x[])", 32));
- TEST_DO(assertClusterSize("tensor(x[],x2[],x3[],x4[],x5[],x6[])", 32));
- TEST_DO(assertClusterSize("tensor(x[],x2[],x3[],x4[],x5[],x6[],x7[])", 64));
+ TEST_DO(assertArraySize("tensor(x[1])", 32));
+ TEST_DO(assertArraySize("tensor(x[10])", 96));
+ TEST_DO(assertArraySize("tensor(x[3])", 32));
+ TEST_DO(assertArraySize("tensor(x[3],y[])", 32));
+ TEST_DO(assertArraySize("tensor(x[3],y[],z[])", 32));
+ TEST_DO(assertArraySize("tensor(x[3],y[],z[],z2[])", 64));
+ TEST_DO(assertArraySize("tensor(x[10],y[10])", 800));
+ TEST_DO(assertArraySize("tensor(x[])", 32));
+ TEST_DO(assertArraySize("tensor(x[],x2[],x3[],x4[],x5[],x6[])", 32));
+ TEST_DO(assertArraySize("tensor(x[],x2[],x3[],x4[],x5[],x6[],x7[])", 64));
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp b/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp
index 2d991c7d565..9b159fadd78 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp
@@ -31,7 +31,7 @@ EnumStoreBase::EnumBufferType::EnumBufferType()
}
size_t
-EnumStoreBase::EnumBufferType::calcClustersToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const
+EnumStoreBase::EnumBufferType::calcArraysToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const
{
(void) resizing;
size_t reservedElements = getReservedElements(bufferId);
@@ -40,24 +40,24 @@ EnumStoreBase::EnumBufferType::calcClustersToAlloc(uint32_t bufferId, size_t siz
if (_lastUsedElems != nullptr) {
usedElems += *_lastUsedElems;
}
- assert((usedElems % _clusterSize) == 0);
+ assert((usedElems % _arraySize) == 0);
double growRatio = 1.5f;
- uint64_t maxSize = static_cast<uint64_t>(_maxClusters) * _clusterSize;
+ uint64_t maxSize = static_cast<uint64_t>(_maxArrays) * _arraySize;
uint64_t newSize = usedElems - _deadElems + sizeNeeded;
if (usedElems != 0) {
newSize *= growRatio;
}
newSize += reservedElements;
newSize = alignBufferSize(newSize);
- assert((newSize % _clusterSize) == 0);
+ assert((newSize % _arraySize) == 0);
if (newSize <= maxSize) {
- return newSize / _clusterSize;
+ return newSize / _arraySize;
}
newSize = usedElems - _deadElems + sizeNeeded + reservedElements + 1000000;
newSize = alignBufferSize(newSize);
- assert((newSize % _clusterSize) == 0);
+ assert((newSize % _arraySize) == 0);
if (newSize <= maxSize) {
- return _maxClusters;
+ return _maxArrays;
}
failNewSize(newSize, maxSize);
return 0;
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstorebase.h b/searchlib/src/vespa/searchlib/attribute/enumstorebase.h
index 6b5ba3eca56..48fbdd69ea1 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstorebase.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstorebase.h
@@ -219,7 +219,7 @@ protected:
public:
EnumBufferType();
- size_t calcClustersToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const override;
+ size_t calcArraysToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const override;
void setSizeNeededAndDead(uint64_t sizeNeeded, uint64_t deadElems) {
_minSizeNeeded = sizeNeeded;
diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp
index 67257286a70..bc375845290 100644
--- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp
@@ -9,7 +9,7 @@ namespace {
// minimum dead bytes in multi value mapping before consider compaction
constexpr size_t DEAD_BYTES_SLACK = 0x10000u;
-constexpr size_t DEAD_CLUSTERS_SLACK = 0x10000u;
+constexpr size_t DEAD_ARRAYS_SLACK = 0x10000u;
}
@@ -86,12 +86,12 @@ MultiValueMappingBase::considerCompact(const CompactionStrategy &compactionStrat
{
size_t usedBytes = _cachedArrayStoreMemoryUsage.usedBytes();
size_t deadBytes = _cachedArrayStoreMemoryUsage.deadBytes();
- size_t usedClusters = _cachedArrayStoreAddressSpaceUsage.used();
- size_t deadClusters = _cachedArrayStoreAddressSpaceUsage.dead();
+ size_t usedArrays = _cachedArrayStoreAddressSpaceUsage.used();
+ size_t deadArrays = _cachedArrayStoreAddressSpaceUsage.dead();
bool compactMemory = ((deadBytes >= DEAD_BYTES_SLACK) &&
(usedBytes * compactionStrategy.getMaxDeadBytesRatio() < deadBytes));
- bool compactAddressSpace = ((deadClusters >= DEAD_CLUSTERS_SLACK) &&
- (usedClusters * compactionStrategy.getMaxDeadAddressSpaceRatio() < deadClusters));
+ bool compactAddressSpace = ((deadArrays >= DEAD_ARRAYS_SLACK) &&
+ (usedArrays * compactionStrategy.getMaxDeadAddressSpaceRatio() < deadArrays));
if (compactMemory || compactAddressSpace) {
compactWorst(compactMemory, compactAddressSpace);
return true;
diff --git a/searchlib/src/vespa/searchlib/btree/btreenodestore.h b/searchlib/src/vespa/searchlib/btree/btreenodestore.h
index 00f5f5e8e70..42f8929b130 100644
--- a/searchlib/src/vespa/searchlib/btree/btreenodestore.h
+++ b/searchlib/src/vespa/searchlib/btree/btreenodestore.h
@@ -22,11 +22,11 @@ class BTreeNodeBufferType : public datastore::BufferType<EntryType>
{
typedef datastore::BufferType<EntryType> ParentType;
using ParentType::_emptyEntry;
- using ParentType::_clusterSize;
+ using ParentType::_arraySize;
using CleanContext = typename ParentType::CleanContext;
public:
- BTreeNodeBufferType(uint32_t minClusters, uint32_t maxClusters)
- : ParentType(1, minClusters, maxClusters)
+ BTreeNodeBufferType(uint32_t minArrays, uint32_t maxArrays)
+ : ParentType(1, minArrays, maxArrays)
{
_emptyEntry.freeze();
}
@@ -62,7 +62,7 @@ public:
private:
- static constexpr size_t MIN_CLUSTERS = 128u;
+ static constexpr size_t MIN_BUFFER_ARRAYS = 128u;
DataStoreType _store;
BTreeNodeBufferType<InternalNodeType> _internalNodeType;
BTreeNodeBufferType<LeafNodeType> _leafNodeType;
diff --git a/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp b/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp
index d005e9d7e3a..333db203175 100644
--- a/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp
+++ b/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp
@@ -39,8 +39,8 @@ template <typename KeyT, typename DataT, typename AggrT,
BTreeNodeStore<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>::
BTreeNodeStore()
: _store(),
- _internalNodeType(MIN_CLUSTERS, RefType::offsetSize()),
- _leafNodeType(MIN_CLUSTERS, RefType::offsetSize())
+ _internalNodeType(MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _leafNodeType(MIN_BUFFER_ARRAYS, RefType::offsetSize())
{
_store.addType(&_internalNodeType);
_store.addType(&_leafNodeType);
diff --git a/searchlib/src/vespa/searchlib/btree/btreestore.h b/searchlib/src/vespa/searchlib/btree/btreestore.h
index 6406980ce08..5f5a8ff0d88 100644
--- a/searchlib/src/vespa/searchlib/btree/btreestore.h
+++ b/searchlib/src/vespa/searchlib/btree/btreestore.h
@@ -391,7 +391,7 @@ public:
foreach_frozen(EntryRef ref, FunctionType func) const;
private:
- static constexpr size_t MIN_CLUSTERS = 128u;
+ static constexpr size_t MIN_BUFFER_ARRAYS = 128u;
template <typename FunctionType, bool Frozen>
void
foreach_key(EntryRef ref, FunctionType func) const;
diff --git a/searchlib/src/vespa/searchlib/btree/btreestore.hpp b/searchlib/src/vespa/searchlib/btree/btreestore.hpp
index b4d82a9e31a..ae9a67b4e8b 100644
--- a/searchlib/src/vespa/searchlib/btree/btreestore.hpp
+++ b/searchlib/src/vespa/searchlib/btree/btreestore.hpp
@@ -23,15 +23,15 @@ template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
BTreeStore<KeyT, DataT, AggrT, CompareT, TraitsT, AggrCalcT>::
BTreeStore(bool init)
: _store(),
- _treeType(1, MIN_CLUSTERS, RefType::offsetSize()),
- _small1Type(1, MIN_CLUSTERS, RefType::offsetSize()),
- _small2Type(2, MIN_CLUSTERS, RefType::offsetSize()),
- _small3Type(3, MIN_CLUSTERS, RefType::offsetSize()),
- _small4Type(4, MIN_CLUSTERS, RefType::offsetSize()),
- _small5Type(5, MIN_CLUSTERS, RefType::offsetSize()),
- _small6Type(6, MIN_CLUSTERS, RefType::offsetSize()),
- _small7Type(7, MIN_CLUSTERS, RefType::offsetSize()),
- _small8Type(8, MIN_CLUSTERS, RefType::offsetSize()),
+ _treeType(1, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small1Type(1, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small2Type(2, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small3Type(3, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small4Type(4, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small5Type(5, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small6Type(6, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small7Type(7, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
+ _small8Type(8, MIN_BUFFER_ARRAYS, RefType::offsetSize()),
_allocator(),
_aggrCalc(),
_builder(_allocator, _aggrCalc)
diff --git a/searchlib/src/vespa/searchlib/datastore/allocator.hpp b/searchlib/src/vespa/searchlib/datastore/allocator.hpp
index 9c4f8568924..553a4e0e30d 100644
--- a/searchlib/src/vespa/searchlib/datastore/allocator.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/allocator.hpp
@@ -38,7 +38,7 @@ Allocator<EntryT, RefT>::allocArray(ConstArrayRef array)
uint32_t activeBufferId = _store.getActiveBufferId(_typeId);
BufferState &state = _store.getBufferState(activeBufferId);
assert(state.isActive());
- assert(state.getClusterSize() == array.size());
+ assert(state.getArraySize() == array.size());
size_t oldBufferSize = state.size();
EntryT *buf = _store.template getBufferEntry<EntryT>(activeBufferId, oldBufferSize);
for (size_t i = 0; i < array.size(); ++i) {
@@ -57,7 +57,7 @@ Allocator<EntryT, RefT>::allocArray(size_t size)
uint32_t activeBufferId = _store.getActiveBufferId(_typeId);
BufferState &state = _store.getBufferState(activeBufferId);
assert(state.isActive());
- assert(state.getClusterSize() == size);
+ assert(state.getArraySize() == size);
size_t oldBufferSize = state.size();
EntryT *buf = _store.template getBufferEntry<EntryT>(activeBufferId, oldBufferSize);
for (size_t i = 0; i < size; ++i) {
diff --git a/searchlib/src/vespa/searchlib/datastore/array_store.hpp b/searchlib/src/vespa/searchlib/datastore/array_store.hpp
index 14c6a43fe09..6867593518d 100644
--- a/searchlib/src/vespa/searchlib/datastore/array_store.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/array_store.hpp
@@ -9,8 +9,6 @@
namespace search::datastore {
-constexpr size_t MIN_BUFFER_CLUSTERS = 8192;
-
template <typename EntryT, typename RefT>
ArrayStore<EntryT, RefT>::LargeArrayType::LargeArrayType(const AllocSpec &spec)
: BufferType<LargeArray>(1, spec.minArraysInBuffer, spec.maxArraysInBuffer, spec.numArraysForNewBuffer, spec.allocGrowFactor)
diff --git a/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp b/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp
index 06922835733..157a73ddc20 100644
--- a/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp
+++ b/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp
@@ -19,15 +19,15 @@ BufferTypeBase::CleanContext::extraBytesCleaned(uint64_t value)
_extraBytes -= value;
}
-BufferTypeBase::BufferTypeBase(uint32_t clusterSize,
- uint32_t minClusters,
- uint32_t maxClusters,
- uint32_t numClustersForNewBuffer,
+BufferTypeBase::BufferTypeBase(uint32_t arraySize,
+ uint32_t minArrays,
+ uint32_t maxArrays,
+ uint32_t numArraysForNewBuffer,
float allocGrowFactor)
- : _clusterSize(clusterSize),
- _minClusters(std::min(minClusters, maxClusters)),
- _maxClusters(maxClusters),
- _numClustersForNewBuffer(std::min(numClustersForNewBuffer, maxClusters)),
+ : _arraySize(arraySize),
+ _minArrays(std::min(minArrays, maxArrays)),
+ _maxArrays(maxArrays),
+ _numArraysForNewBuffer(std::min(numArraysForNewBuffer, maxArrays)),
_allocGrowFactor(allocGrowFactor),
_activeBuffers(0),
_holdBuffers(0),
@@ -37,10 +37,10 @@ BufferTypeBase::BufferTypeBase(uint32_t clusterSize,
{
}
-BufferTypeBase::BufferTypeBase(uint32_t clusterSize,
- uint32_t minClusters,
- uint32_t maxClusters)
- : BufferTypeBase(clusterSize, minClusters, maxClusters, 0u, DEFAULT_ALLOC_GROW_FACTOR)
+BufferTypeBase::BufferTypeBase(uint32_t arraySize,
+ uint32_t minArrays,
+ uint32_t maxArrays)
+ : BufferTypeBase(arraySize, minArrays, maxArrays, 0u, DEFAULT_ALLOC_GROW_FACTOR)
{
}
@@ -56,7 +56,7 @@ BufferTypeBase::~BufferTypeBase()
size_t
BufferTypeBase::getReservedElements(uint32_t bufferId) const
{
- return bufferId == 0 ? _clusterSize : 0u;
+ return bufferId == 0 ? _arraySize : 0u;
}
void
@@ -74,11 +74,11 @@ BufferTypeBase::onActive(uint32_t bufferId, size_t *usedElems, size_t &deadElems
flushLastUsed();
++_activeBuffers;
_lastUsedElems = usedElems;
- size_t reservedElements = getReservedElements(bufferId);
- if (reservedElements != 0u) {
- initializeReservedElements(buffer, reservedElements);
- *usedElems = reservedElements;
- deadElems = reservedElements;
+ size_t reservedElems = getReservedElements(bufferId);
+ if (reservedElems != 0u) {
+ initializeReservedElements(buffer, reservedElems);
+ *usedElems = reservedElems;
+ deadElems = reservedElems;
}
}
@@ -104,35 +104,35 @@ BufferTypeBase::onFree(size_t usedElems)
}
void
-BufferTypeBase::clampMaxClusters(uint32_t maxClusters)
+BufferTypeBase::clampMaxArrays(uint32_t maxArrays)
{
- _maxClusters = std::min(_maxClusters, maxClusters);
- _minClusters = std::min(_minClusters, _maxClusters);
- _numClustersForNewBuffer = std::min(_numClustersForNewBuffer, _maxClusters);
+ _maxArrays = std::min(_maxArrays, maxArrays);
+ _minArrays = std::min(_minArrays, _maxArrays);
+ _numArraysForNewBuffer = std::min(_numArraysForNewBuffer, _maxArrays);
}
size_t
-BufferTypeBase::calcClustersToAlloc(uint32_t bufferId, size_t elementsNeeded, bool resizing) const
+BufferTypeBase::calcArraysToAlloc(uint32_t bufferId, size_t elemsNeeded, bool resizing) const
{
- size_t reservedElements = getReservedElements(bufferId);
+ size_t reservedElems = getReservedElements(bufferId);
size_t usedElems = (resizing ? 0 : _activeUsedElems);
if (_lastUsedElems != nullptr) {
usedElems += *_lastUsedElems;
}
- assert((usedElems % _clusterSize) == 0);
- size_t usedClusters = usedElems / _clusterSize;
- size_t needClusters = (elementsNeeded + (resizing ? usedElems : reservedElements) + _clusterSize - 1) / _clusterSize;
- size_t growClusters = (usedClusters * _allocGrowFactor);
- size_t wantClusters = std::max((resizing ? usedClusters : 0u) + growClusters,
- static_cast<size_t>(_minClusters));
- size_t result = wantClusters;
- if (result < needClusters) {
- result = needClusters;
+ assert((usedElems % _arraySize) == 0);
+ size_t usedArrays = usedElems / _arraySize;
+ size_t neededArrays = (elemsNeeded + (resizing ? usedElems : reservedElems) + _arraySize - 1) / _arraySize;
+ size_t growArrays = (usedArrays * _allocGrowFactor);
+ size_t wantedArrays = std::max((resizing ? usedArrays : 0u) + growArrays,
+ static_cast<size_t>(_minArrays));
+ size_t result = wantedArrays;
+ if (result < neededArrays) {
+ result = neededArrays;
}
- if (result > _maxClusters) {
- result = _maxClusters;
+ if (result > _maxArrays) {
+ result = _maxArrays;
}
- assert(result >= needClusters);
+ assert(result >= neededArrays);
return result;
}
diff --git a/searchlib/src/vespa/searchlib/datastore/buffer_type.h b/searchlib/src/vespa/searchlib/datastore/buffer_type.h
index 2ec66e3aae3..55a394b986a 100644
--- a/searchlib/src/vespa/searchlib/datastore/buffer_type.h
+++ b/searchlib/src/vespa/searchlib/datastore/buffer_type.h
@@ -8,17 +8,20 @@
namespace search::datastore {
/**
- * Class used manage allocation and de-allocation of a specific data type in
- * the underlying buffers in a data store.
+ * Abstract class used to manage allocation and de-allocation of a specific data type in underlying memory buffers in a data store.
+ * Each buffer is owned by an instance of BufferState.
+ *
+ * This class handles allocation of both single elements (_arraySize = 1) and array of elements (_arraySize > 1).
+ * The strategy for how to grow buffers is specified as well.
*/
class BufferTypeBase
{
protected:
- uint32_t _clusterSize; // Number of elements in an allocation unit
- uint32_t _minClusters; // Minimum number of clusters to allocate
- uint32_t _maxClusters; // Maximum number of clusters to allocate
- // Number of clusters needed before allocating a new buffer instead of just resizing the first one
- uint32_t _numClustersForNewBuffer;
+ uint32_t _arraySize; // Number of elements in an allocation unit
+ uint32_t _minArrays; // Minimum number of arrays to allocate in a buffer
+ uint32_t _maxArrays; // Maximum number of arrays to allocate in a buffer
+ // 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;
@@ -37,12 +40,12 @@ public:
BufferTypeBase(const BufferTypeBase &rhs) = delete;
BufferTypeBase & operator=(const BufferTypeBase &rhs) = delete;
- BufferTypeBase(uint32_t clusterSize, uint32_t minClusters, uint32_t maxClusters);
- BufferTypeBase(uint32_t clusterSize, uint32_t minClusters, uint32_t maxClusters,
- uint32_t numClustersForNewBuffer, float allocGrowFactor);
+ BufferTypeBase(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays);
+ BufferTypeBase(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays,
+ uint32_t numArraysForNewBuffer, float allocGrowFactor);
virtual ~BufferTypeBase();
- virtual void destroyElements(void *buffer, size_t numElements) = 0;
- virtual void fallbackCopy(void *newBuffer, const void *oldBuffer, size_t numElements) = 0;
+ virtual void destroyElements(void *buffer, size_t numElems) = 0;
+ virtual void fallbackCopy(void *newBuffer, const void *oldBuffer, size_t numElems) = 0;
// Return number of reserved elements at start of buffer, to avoid
// invalid reference and handle data at negative offset (alignment
// hacks) as used by dense tensor store.
@@ -50,60 +53,58 @@ public:
// Initialize reserved elements at start of buffer.
virtual void initializeReservedElements(void *buffer, size_t reservedElements) = 0;
virtual size_t elementSize() const = 0;
- virtual void cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext cleanCtx) = 0;
- size_t getClusterSize() const { return _clusterSize; }
+ virtual void cleanHold(void *buffer, uint64_t offset, uint64_t numElems, CleanContext cleanCtx) = 0;
+ size_t getArraySize() const { return _arraySize; }
void flushLastUsed();
virtual void onActive(uint32_t bufferId, size_t *usedElems, size_t &deadElems, void *buffer);
void onHold(const size_t *usedElems);
virtual void onFree(size_t usedElems);
/**
- * Calculate number of clusters to allocate for new buffer.
- *
- * @param elementsNeeded number of elements needed now
- * @param clusterRefSize number of clusters expressable via reference type
- *
- * @return number of clusters to allocate for new buffer
+ * Calculate number of arrays to allocate for new buffer given how many elements are needed.
*/
- virtual size_t calcClustersToAlloc(uint32_t bufferId, size_t elementsNeeded, bool resizing) const;
+ virtual size_t calcArraysToAlloc(uint32_t bufferId, size_t elementsNeeded, bool resizing) const;
- void clampMaxClusters(uint32_t maxClusters);
+ void clampMaxArrays(uint32_t maxArrays);
uint32_t getActiveBuffers() const { return _activeBuffers; }
- size_t getMaxClusters() const { return _maxClusters; }
- uint32_t getNumClustersForNewBuffer() const { return _numClustersForNewBuffer; }
+ size_t getMaxArrays() const { return _maxArrays; }
+ uint32_t getNumArraysForNewBuffer() const { return _numArraysForNewBuffer; }
};
-
+/**
+ * Concrete class used to manage allocation and de-allocation of elements of type EntryType in data store buffers.
+ */
template <typename EntryType>
class BufferType : public BufferTypeBase
{
-public:
+protected:
EntryType _emptyEntry;
+public:
BufferType(const BufferType &rhs) = delete;
BufferType & operator=(const BufferType &rhs) = delete;
- BufferType(uint32_t clusterSize, uint32_t minClusters, uint32_t maxClusters);
- BufferType(uint32_t clusterSize, uint32_t minClusters, uint32_t maxClusters,
- uint32_t numClustersForNewBuffer, float allocGrowFactor);
+ BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays);
+ BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays,
+ uint32_t numArraysForNewBuffer, float allocGrowFactor);
~BufferType();
- void destroyElements(void *buffer, size_t numElements) override;
- void fallbackCopy(void *newBuffer, const void *oldBuffer, size_t numElements) override;
+ void destroyElements(void *buffer, size_t numElems) override;
+ void fallbackCopy(void *newBuffer, const void *oldBuffer, size_t numElems) override;
void initializeReservedElements(void *buffer, size_t reservedElements) override;
- void cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext cleanCxt) override;
+ void cleanHold(void *buffer, uint64_t offset, uint64_t numElems, CleanContext cleanCxt) override;
size_t elementSize() const override { return sizeof(EntryType); }
};
template <typename EntryType>
-BufferType<EntryType>::BufferType(uint32_t clusterSize, uint32_t minClusters, uint32_t maxClusters)
- : BufferTypeBase(clusterSize, minClusters, maxClusters),
+BufferType<EntryType>::BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays)
+ : BufferTypeBase(arraySize, minArrays, maxArrays),
_emptyEntry()
{ }
template <typename EntryType>
-BufferType<EntryType>::BufferType(uint32_t clusterSize, uint32_t minClusters, uint32_t maxClusters,
- uint32_t numClustersForNewBuffer, float allocGrowFactor)
- : BufferTypeBase(clusterSize, minClusters, maxClusters, numClustersForNewBuffer, allocGrowFactor),
+BufferType<EntryType>::BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays,
+ uint32_t numArraysForNewBuffer, float allocGrowFactor)
+ : BufferTypeBase(arraySize, minArrays, maxArrays, numArraysForNewBuffer, allocGrowFactor),
_emptyEntry()
{ }
@@ -112,10 +113,10 @@ BufferType<EntryType>::~BufferType() { }
template <typename EntryType>
void
-BufferType<EntryType>::destroyElements(void *buffer, size_t numElements)
+BufferType<EntryType>::destroyElements(void *buffer, size_t numElems)
{
EntryType *e = static_cast<EntryType *>(buffer);
- for (size_t j = numElements; j != 0; --j) {
+ for (size_t j = numElems; j != 0; --j) {
e->~EntryType();
++e;
}
@@ -125,11 +126,11 @@ template <typename EntryType>
void
BufferType<EntryType>::fallbackCopy(void *newBuffer,
const void *oldBuffer,
- size_t numElements)
+ size_t numElems)
{
EntryType *d = static_cast<EntryType *>(newBuffer);
const EntryType *s = static_cast<const EntryType *>(oldBuffer);
- for (size_t j = numElements; j != 0; --j) {
+ for (size_t j = numElems; j != 0; --j) {
new (static_cast<void *>(d)) EntryType(*s);
++s;
++d;
@@ -149,10 +150,10 @@ BufferType<EntryType>::initializeReservedElements(void *buffer, size_t reservedE
template <typename EntryType>
void
-BufferType<EntryType>::cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext)
+BufferType<EntryType>::cleanHold(void *buffer, uint64_t offset, uint64_t numElems, CleanContext)
{
EntryType *e = static_cast<EntryType *>(buffer) + offset;
- for (size_t j = len; j != 0; --j) {
+ for (size_t j = numElems; j != 0; --j) {
*e = _emptyEntry;
++e;
}
diff --git a/searchlib/src/vespa/searchlib/datastore/bufferstate.cpp b/searchlib/src/vespa/searchlib/datastore/bufferstate.cpp
index de4ac9f6fc2..3424546a79f 100644
--- a/searchlib/src/vespa/searchlib/datastore/bufferstate.cpp
+++ b/searchlib/src/vespa/searchlib/datastore/bufferstate.cpp
@@ -29,7 +29,7 @@ BufferState::BufferState()
_prevHasFree(NULL),
_typeHandler(NULL),
_typeId(0),
- _clusterSize(0),
+ _arraySize(0),
_compacting(false),
_buffer(Alloc::alloc(0, MemoryAllocator::HUGEPAGE_SIZE))
{
@@ -77,10 +77,10 @@ calcAllocation(uint32_t bufferId,
size_t elementsNeeded,
bool resizing)
{
- size_t allocClusters = typeHandler.calcClustersToAlloc(bufferId, elementsNeeded, resizing);
- size_t allocElements = allocClusters * typeHandler.getClusterSize();
+ size_t allocArrays = typeHandler.calcArraysToAlloc(bufferId, elementsNeeded, resizing);
+ size_t allocElements = allocArrays * typeHandler.getArraySize();
size_t allocBytes = roundUpToMatchAllocator(allocElements * typeHandler.elementSize());
- size_t maxAllocBytes = typeHandler.getMaxClusters() * typeHandler.getClusterSize() * typeHandler.elementSize();
+ size_t maxAllocBytes = typeHandler.getMaxArrays() * typeHandler.getArraySize() * typeHandler.elementSize();
if (allocBytes > maxAllocBytes) {
// Ensure that allocated bytes does not exceed the maximum handled by this type.
allocBytes = maxAllocBytes;
@@ -123,7 +123,7 @@ BufferState::onActive(uint32_t bufferId, uint32_t typeId,
_state = ACTIVE;
_typeHandler = typeHandler;
_typeId = typeId;
- _clusterSize = _typeHandler->getClusterSize();
+ _arraySize = _typeHandler->getArraySize();
typeHandler->onActive(bufferId, &_usedElems, _deadElems, buffer);
}
@@ -170,7 +170,7 @@ BufferState::onFree(void *&buffer)
_extraHoldBytes = 0;
_state = FREE;
_typeHandler = NULL;
- _clusterSize = 0;
+ _arraySize = 0;
assert(_freeList.empty());
assert(_nextHasFree == NULL);
assert(_prevHasFree == NULL);
diff --git a/searchlib/src/vespa/searchlib/datastore/bufferstate.h b/searchlib/src/vespa/searchlib/datastore/bufferstate.h
index 15c8202a525..696568720c0 100644
--- a/searchlib/src/vespa/searchlib/datastore/bufferstate.h
+++ b/searchlib/src/vespa/searchlib/datastore/bufferstate.h
@@ -12,6 +12,13 @@ namespace search::datastore {
/**
* Represents a memory allocated buffer (used in a data store) with its state.
+ *
+ * This class has no direct knowledge of what kind of data is stored in the buffer.
+ * It uses a type handler (BufferTypeBase) to calculate how much memory to allocate,
+ * and how to destruct elements in a buffer.
+ *
+ * It also supports use of free lists, where previously allocated elements can be re-used.
+ * First the element is put on hold, then on the free list (counted as dead).
*/
class BufferState
{
@@ -57,7 +64,7 @@ private:
BufferTypeBase *_typeHandler;
uint32_t _typeId;
- uint32_t _clusterSize;
+ uint32_t _arraySize;
bool _compacting;
Alloc _buffer;
@@ -128,7 +135,7 @@ public:
if (_freeList.empty()) {
removeFromFreeListList();
}
- _deadElems -= _clusterSize;
+ _deadElems -= _arraySize;
return ret;
}
@@ -144,7 +151,7 @@ public:
}
void dropBuffer(void *&buffer);
uint32_t getTypeId() const { return _typeId; }
- uint32_t getClusterSize() const { return _clusterSize; }
+ uint32_t getArraySize() const { return _arraySize; }
uint64_t getDeadElems() const { return _deadElems; }
uint64_t getHoldElems() const { return _holdElems; }
size_t getExtraUsedBytes() const { return _extraUsedBytes; }
diff --git a/searchlib/src/vespa/searchlib/datastore/datastore.h b/searchlib/src/vespa/searchlib/datastore/datastore.h
index 316ec34dc85..c0fccdfb776 100644
--- a/searchlib/src/vespa/searchlib/datastore/datastore.h
+++ b/searchlib/src/vespa/searchlib/datastore/datastore.h
@@ -21,6 +21,9 @@ struct DefaultReclaimer {
namespace search::datastore {
+/**
+ * Concrete data store using the given EntryRef type to reference stored data.
+ */
template <typename RefT = EntryRefT<22> >
class DataStoreT : public DataStoreBase
{
@@ -39,20 +42,20 @@ public:
* @param ref Reference to dead stored features
* @param dead Number of newly dead elements
*/
- void incDead(EntryRef ref, uint64_t dead) {
+ void incDead(EntryRef ref, uint64_t deadElems) {
RefType intRef(ref);
- DataStoreBase::incDead(intRef.bufferId(), dead);
+ DataStoreBase::incDead(intRef.bufferId(), deadElems);
}
/**
- * Free element.
+ * Free element(s).
*/
- void freeElem(EntryRef ref, uint64_t len);
+ void freeElem(EntryRef ref, uint64_t numElems);
/**
- * Hold element.
+ * Hold element(s).
*/
- void holdElem(EntryRef ref, uint64_t len, size_t extraBytes = 0);
+ void holdElem(EntryRef ref, uint64_t numElems, size_t extraBytes = 0);
/**
* Trim elem hold list, freeing elements that no longer needs to be held.
@@ -81,7 +84,9 @@ public:
};
-
+/**
+ * Concrete data store storing elements of type EntryType, using the given EntryRef type to reference stored data.
+ */
template <typename EntryType, typename RefT = EntryRefT<22> >
class DataStore : public DataStoreT<RefT>
{
diff --git a/searchlib/src/vespa/searchlib/datastore/datastore.hpp b/searchlib/src/vespa/searchlib/datastore/datastore.hpp
index 39706957e2d..aa242d5b968 100644
--- a/searchlib/src/vespa/searchlib/datastore/datastore.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/datastore.hpp
@@ -18,21 +18,19 @@ DataStoreT<RefT>::DataStoreT()
{
}
-
template <typename RefT>
DataStoreT<RefT>::~DataStoreT()
{
}
-
template <typename RefT>
void
-DataStoreT<RefT>::freeElem(EntryRef ref, uint64_t len)
+DataStoreT<RefT>::freeElem(EntryRef ref, uint64_t numElems)
{
RefType intRef(ref);
BufferState &state = getBufferState(intRef.bufferId());
if (state.isActive()) {
- if (state.freeListList() != NULL && len == state.getClusterSize()) {
+ if (state.freeListList() != NULL && numElems == state.getArraySize()) {
if (state.freeList().empty()) {
state.addToFreeListList();
}
@@ -41,19 +39,18 @@ DataStoreT<RefT>::freeElem(EntryRef ref, uint64_t len)
} else {
assert(state.isOnHold());
}
- state.incDeadElems(len);
+ state.incDeadElems(numElems);
state.cleanHold(getBuffer(intRef.bufferId()),
(intRef.offset() / RefType::align(1)) *
- state.getClusterSize(), len);
+ state.getArraySize(), numElems);
}
-
template <typename RefT>
void
-DataStoreT<RefT>::holdElem(EntryRef ref, uint64_t len, size_t extraBytes)
+DataStoreT<RefT>::holdElem(EntryRef ref, uint64_t numElems, size_t extraBytes)
{
RefType intRef(ref);
- uint64_t alignedLen = RefType::align(len);
+ uint64_t alignedLen = RefType::align(numElems);
BufferState &state = getBufferState(intRef.bufferId());
assert(state.isActive());
if (state.hasDisabledElemHoldList()) {
@@ -65,7 +62,6 @@ DataStoreT<RefT>::holdElem(EntryRef ref, uint64_t len, size_t extraBytes)
state.incExtraHoldBytes(extraBytes);
}
-
template <typename RefT>
void
DataStoreT<RefT>::trimElemHoldList(generation_t usedGen)
@@ -89,7 +85,6 @@ DataStoreT<RefT>::trimElemHoldList(generation_t usedGen)
}
}
-
template <typename RefT>
void
DataStoreT<RefT>::clearElemHoldList()
diff --git a/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp b/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp
index 29621e79a59..c922c337a18 100644
--- a/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp
+++ b/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp
@@ -26,21 +26,22 @@ constexpr size_t TOODEAD_SLACK = 0x4000u;
* up completely will be wasted work, as data will have to be moved again
* rather soon.
*/
-bool activeWriteBufferTooDead(const BufferState &state)
+bool
+activeWriteBufferTooDead(const BufferState &state)
{
size_t deadElems = state.getDeadElems();
- size_t deadBytes = deadElems * state.getClusterSize();
+ size_t deadBytes = deadElems * state.getArraySize();
return ((deadBytes >= TOODEAD_SLACK) && (deadElems * 2 >= state.size()));
}
}
-DataStoreBase::FallbackHold::FallbackHold(size_t size,
- BufferState::Alloc &&buffer,
- size_t usedElems,
- BufferTypeBase *typeHandler,
- uint32_t typeId)
- : GenerationHeldBase(size),
+DataStoreBase::FallbackHold::FallbackHold(size_t bytesSize,
+ BufferState::Alloc &&buffer,
+ size_t usedElems,
+ BufferTypeBase *typeHandler,
+ uint32_t typeId)
+ : GenerationHeldBase(bytesSize),
_buffer(std::move(buffer)),
_usedElems(usedElems),
_typeHandler(typeHandler),
@@ -48,21 +49,18 @@ DataStoreBase::FallbackHold::FallbackHold(size_t size,
{
}
-
DataStoreBase::FallbackHold::~FallbackHold()
{
_typeHandler->destroyElements(_buffer.get(), _usedElems);
}
-
-class DataStoreBase::BufferHold : public GenerationHeldBase
-{
+class DataStoreBase::BufferHold : public GenerationHeldBase {
DataStoreBase &_dsb;
uint32_t _bufferId;
public:
- BufferHold(size_t size, DataStoreBase &dsb, uint32_t bufferId)
- : GenerationHeldBase(size),
+ BufferHold(size_t bytesSize, DataStoreBase &dsb, uint32_t bufferId)
+ : GenerationHeldBase(bytesSize),
_dsb(dsb),
_bufferId(bufferId)
{
@@ -74,8 +72,7 @@ public:
}
};
-
-DataStoreBase::DataStoreBase(uint32_t numBuffers, size_t maxClusters)
+DataStoreBase::DataStoreBase(uint32_t numBuffers, size_t maxArrays)
: _buffers(numBuffers),
_activeBufferIds(),
_states(numBuffers),
@@ -86,12 +83,11 @@ DataStoreBase::DataStoreBase(uint32_t numBuffers, size_t maxClusters)
_elemHold1List(),
_elemHold2List(),
_numBuffers(numBuffers),
- _maxClusters(maxClusters),
+ _maxArrays(maxArrays),
_genHolder()
{
}
-
DataStoreBase::~DataStoreBase()
{
disableFreeLists();
@@ -100,37 +96,34 @@ DataStoreBase::~DataStoreBase()
assert(_elemHold2List.empty());
}
-
void
-DataStoreBase::switchActiveBuffer(uint32_t typeId, size_t sizeNeeded)
+DataStoreBase::switchActiveBuffer(uint32_t typeId, size_t elemsNeeded)
{
size_t activeBufferId = _activeBufferIds[typeId];
do {
// start using next buffer
activeBufferId = nextBufferId(activeBufferId);
} while (!_states[activeBufferId].isFree());
- onActive(activeBufferId, typeId, sizeNeeded);
+ onActive(activeBufferId, typeId, elemsNeeded);
_activeBufferIds[typeId] = activeBufferId;
}
-
void
-DataStoreBase::switchOrGrowActiveBuffer(uint32_t typeId, size_t sizeNeeded)
+DataStoreBase::switchOrGrowActiveBuffer(uint32_t typeId, size_t elemsNeeded)
{
auto typeHandler = _typeHandlers[typeId];
- uint32_t clusterSize = typeHandler->getClusterSize();
- size_t numClustersForNewBuffer = typeHandler->getNumClustersForNewBuffer();
- size_t numEntriesForNewBuffer = numClustersForNewBuffer * clusterSize;
+ uint32_t arraySize = typeHandler->getArraySize();
+ size_t numArraysForNewBuffer = typeHandler->getNumArraysForNewBuffer();
+ size_t numEntriesForNewBuffer = numArraysForNewBuffer * arraySize;
uint32_t bufferId = _activeBufferIds[typeId];
- if (sizeNeeded + _states[bufferId].size() >= numEntriesForNewBuffer) {
+ if (elemsNeeded + _states[bufferId].size() >= numEntriesForNewBuffer) {
// Don't try to resize existing buffer, new buffer will be large enough
- switchActiveBuffer(typeId, sizeNeeded);
+ switchActiveBuffer(typeId, elemsNeeded);
} else {
- fallbackResize(bufferId, sizeNeeded);
+ fallbackResize(bufferId, elemsNeeded);
}
}
-
void
DataStoreBase::initActiveBuffers()
{
@@ -146,13 +139,12 @@ DataStoreBase::initActiveBuffers()
}
}
-
uint32_t
DataStoreBase::addType(BufferTypeBase *typeHandler)
{
uint32_t typeId = _activeBufferIds.size();
assert(typeId == _typeHandlers.size());
- typeHandler->clampMaxClusters(_maxClusters);
+ typeHandler->clampMaxArrays(_maxArrays);
_activeBufferIds.push_back(0);
_typeHandlers.push_back(typeHandler);
_freeListLists.push_back(BufferState::FreeListList());
@@ -169,32 +161,28 @@ DataStoreBase::transferElemHoldList(generation_t generation)
_elemHold1List.clear();
}
-
void
DataStoreBase::transferHoldLists(generation_t generation)
{
_genHolder.transferHoldLists(generation);
- if (hasElemHold1())
+ if (hasElemHold1()) {
transferElemHoldList(generation);
+ }
}
-
void
DataStoreBase::doneHoldBuffer(uint32_t bufferId)
{
_states[bufferId].onFree(_buffers[bufferId].getBuffer());
}
-
void
DataStoreBase::trimHoldLists(generation_t usedGen)
{
trimElemHoldList(usedGen); // Trim entries before trimming buffers
-
_genHolder.trimHoldLists(usedGen);
}
-
void
DataStoreBase::clearHoldLists()
{
@@ -203,7 +191,6 @@ DataStoreBase::clearHoldLists()
_genHolder.clearHoldLists();
}
-
void
DataStoreBase::dropBuffers()
{
@@ -214,7 +201,6 @@ DataStoreBase::dropBuffers()
_genHolder.clearHoldLists();
}
-
MemoryUsage
DataStoreBase::getMemoryUsage() const
{
@@ -227,7 +213,6 @@ DataStoreBase::getMemoryUsage() const
return usage;
}
-
void
DataStoreBase::holdBuffer(uint32_t bufferId)
{
@@ -237,7 +222,6 @@ DataStoreBase::holdBuffer(uint32_t bufferId)
_genHolder.hold(std::move(hold));
}
-
void
DataStoreBase::enableFreeLists()
{
@@ -250,7 +234,6 @@ DataStoreBase::enableFreeLists()
_freeListsEnabled = true;
}
-
void
DataStoreBase::disableFreeLists()
{
@@ -260,7 +243,6 @@ DataStoreBase::disableFreeLists()
_freeListsEnabled = false;
}
-
void
DataStoreBase::enableFreeList(uint32_t bufferId)
{
@@ -272,14 +254,12 @@ DataStoreBase::enableFreeList(uint32_t bufferId)
}
}
-
void
DataStoreBase::disableFreeList(uint32_t bufferId)
{
- _states[bufferId].setFreeListList(NULL);
+ _states[bufferId].setFreeListList(nullptr);
}
-
void
DataStoreBase::disableElemHoldList()
{
@@ -337,30 +317,30 @@ DataStoreBase::getMemStats() const
AddressSpace
DataStoreBase::getAddressSpaceUsage() const
{
- size_t usedClusters = 0;
- size_t deadClusters = 0;
- size_t limitClusters = 0;
+ size_t usedArrays = 0;
+ size_t deadArrays = 0;
+ size_t limitArrays = 0;
for (const BufferState & bState: _states) {
if (bState.isActive()) {
- uint32_t clusterSize = bState.getClusterSize();
- usedClusters += bState.size() / clusterSize;
- deadClusters += bState.getDeadElems() / clusterSize;
- limitClusters += bState.capacity() / clusterSize;
+ uint32_t arraySize = bState.getArraySize();
+ usedArrays += bState.size() / arraySize;
+ deadArrays += bState.getDeadElems() / arraySize;
+ limitArrays += bState.capacity() / arraySize;
} else if (bState.isOnHold()) {
- uint32_t clusterSize = bState.getClusterSize();
- usedClusters += bState.size() / clusterSize;
- limitClusters += bState.capacity() / clusterSize;
+ uint32_t arraySize = bState.getArraySize();
+ usedArrays += bState.size() / arraySize;
+ limitArrays += bState.capacity() / arraySize;
} else if (bState.isFree()) {
- limitClusters += _maxClusters;
+ limitArrays += _maxArrays;
} else {
LOG_ABORT("should not be reached");
}
}
- return AddressSpace(usedClusters, deadClusters, limitClusters);
+ return AddressSpace(usedArrays, deadArrays, limitArrays);
}
void
-DataStoreBase::onActive(uint32_t bufferId, uint32_t typeId, size_t sizeNeeded)
+DataStoreBase::onActive(uint32_t bufferId, uint32_t typeId, size_t elemsNeeded)
{
assert(typeId < _typeHandlers.size());
assert(bufferId < _numBuffers);
@@ -368,7 +348,7 @@ DataStoreBase::onActive(uint32_t bufferId, uint32_t typeId, size_t sizeNeeded)
BufferState &state = _states[bufferId];
state.onActive(bufferId, typeId,
_typeHandlers[typeId],
- sizeNeeded,
+ elemsNeeded,
_buffers[bufferId].getBuffer());
enableFreeList(bufferId);
}
@@ -400,16 +380,15 @@ DataStoreBase::finishCompact(const std::vector<uint32_t> &toHold)
}
}
-
void
-DataStoreBase::fallbackResize(uint32_t bufferId, uint64_t sizeNeeded)
+DataStoreBase::fallbackResize(uint32_t bufferId, uint64_t elemsNeeded)
{
BufferState &state = getBufferState(bufferId);
BufferState::Alloc toHoldBuffer;
size_t oldUsedElems = state.size();
size_t oldAllocElems = state.capacity();
size_t elementSize = state.getTypeHandler()->elementSize();
- state.fallbackResize(bufferId, sizeNeeded,
+ state.fallbackResize(bufferId, elemsNeeded,
_buffers[bufferId].getBuffer(),
toHoldBuffer);
GenerationHeldBase::UP
@@ -423,9 +402,9 @@ DataStoreBase::fallbackResize(uint32_t bufferId, uint64_t sizeNeeded)
}
}
-
uint32_t
-DataStoreBase::startCompactWorstBuffer(uint32_t typeId) {
+DataStoreBase::startCompactWorstBuffer(uint32_t typeId)
+{
uint32_t activeBufferId = getActiveBufferId(typeId);
const BufferTypeBase *typeHandler = _typeHandlers[typeId];
assert(typeHandler->getActiveBuffers() >= 1u);
@@ -483,12 +462,12 @@ DataStoreBase::startCompactWorstBuffers(bool compactMemory, bool compactAddressS
uint32_t worstMemoryBufferId = noBufferId;
uint32_t worstAddressSpaceBufferId = noBufferId;
size_t worstDeadElems = 0;
- size_t worstDeadClusters = 0;
+ size_t worstDeadArrays = 0;
for (uint32_t bufferId = 0; bufferId < _numBuffers; ++bufferId) {
const auto &state = getBufferState(bufferId);
if (state.isActive()) {
auto typeHandler = state.getTypeHandler();
- uint32_t clusterSize = typeHandler->getClusterSize();
+ uint32_t arraySize = typeHandler->getArraySize();
uint32_t reservedElements = typeHandler->getReservedElements(bufferId);
size_t deadElems = state.getDeadElems() - reservedElements;
if (compactMemory && deadElems > worstDeadElems) {
@@ -496,10 +475,10 @@ DataStoreBase::startCompactWorstBuffers(bool compactMemory, bool compactAddressS
worstDeadElems = deadElems;
}
if (compactAddressSpace) {
- size_t deadClusters = deadElems / clusterSize;
- if (deadClusters > worstDeadClusters) {
+ size_t deadArrays = deadElems / arraySize;
+ if (deadArrays > worstDeadArrays) {
worstAddressSpaceBufferId = bufferId;
- worstDeadClusters = deadClusters;
+ worstDeadArrays = deadArrays;
}
}
}
diff --git a/searchlib/src/vespa/searchlib/datastore/datastorebase.h b/searchlib/src/vespa/searchlib/datastore/datastorebase.h
index eca64c38ea1..d6171dc1c0c 100644
--- a/searchlib/src/vespa/searchlib/datastore/datastorebase.h
+++ b/searchlib/src/vespa/searchlib/datastore/datastorebase.h
@@ -11,6 +11,11 @@
namespace search::datastore {
+/**
+ * Abstract class used to store data of potential different types in underlying memory buffers.
+ *
+ * Reference to stored data is via a 32-bit handle (EntryRef).
+ */
class DataStoreBase
{
public:
@@ -73,7 +78,7 @@ protected:
BufferTypeBase *_typeHandler;
uint32_t _typeId;
- FallbackHold(size_t size, BufferState::Alloc &&buffer, size_t usedElems,
+ FallbackHold(size_t bytesSize, BufferState::Alloc &&buffer, size_t usedElems,
BufferTypeBase *typeHandler, uint32_t typeId);
~FallbackHold() override;
@@ -142,11 +147,11 @@ protected:
ElemHold2List _elemHold2List;
const uint32_t _numBuffers;
- const size_t _maxClusters;
+ const size_t _maxArrays;
vespalib::GenerationHolder _genHolder;
- DataStoreBase(uint32_t numBuffers, size_t maxClusters);
+ DataStoreBase(uint32_t numBuffers, size_t maxArrays);
DataStoreBase(const DataStoreBase &) = delete;
DataStoreBase &operator=(const DataStoreBase &) = delete;
@@ -194,14 +199,14 @@ public:
* Ensure that active buffer has a given number of elements free at end.
* Switch to new buffer if current buffer is too full.
*
- * @param typeId registered data type for buffer.
- * @param sizeNeeded Number of elements needed to be free
+ * @param typeId registered data type for buffer.
+ * @param elemsNeeded Number of elements needed to be free
*/
- void ensureBufferCapacity(uint32_t typeId, size_t sizeNeeded) {
- if (__builtin_expect(sizeNeeded >
+ void ensureBufferCapacity(uint32_t typeId, size_t elemsNeeded) {
+ if (__builtin_expect(elemsNeeded >
_states[_activeBufferIds[typeId]].remaining(),
false)) {
- switchOrGrowActiveBuffer(typeId, sizeNeeded);
+ switchOrGrowActiveBuffer(typeId, elemsNeeded);
}
}
@@ -216,12 +221,12 @@ public:
* Switch to new active buffer, typically in preparation for compaction
* or when current active buffer no longer has free space.
*
- * @param typeId registered data type for buffer.
- * @param sizeNeeded Number of elements needed to be free
+ * @param typeId registered data type for buffer.
+ * @param elemsNeeded Number of elements needed to be free
*/
- void switchActiveBuffer(uint32_t typeId, size_t sizeNeeded);
+ void switchActiveBuffer(uint32_t typeId, size_t elemsNeeded);
- void switchOrGrowActiveBuffer(uint32_t typeId, size_t sizeNeeded);
+ void switchOrGrowActiveBuffer(uint32_t typeId, size_t elemsNeeded);
MemoryUsage getMemoryUsage() const;
@@ -273,9 +278,9 @@ public:
void dropBuffers();
- void incDead(uint32_t bufferId, uint64_t dead) {
+ void incDead(uint32_t bufferId, uint64_t deadElems) {
BufferState &state = _states[bufferId];
- state.incDeadElems(dead);
+ state.incDeadElems(deadElems);
}
/**
@@ -318,11 +323,12 @@ private:
/**
* Switch buffer state to active.
*
- * @param bufferId Id of buffer to be active.
- * @param typeId registered data type for buffer.
- * @param sizeNeeded Number of elements needed to be free
+ * @param bufferId Id of buffer to be active.
+ * @param typeId registered data type for buffer.
+ * @param elemsNeeded Number of elements needed to be free
*/
- void onActive(uint32_t bufferId, uint32_t typeId, size_t sizeNeeded);
+ void onActive(uint32_t bufferId, uint32_t typeId, size_t elemsNeeded);
+
public:
uint32_t getTypeId(uint32_t bufferId) const {
return _buffers[bufferId].getTypeId();
@@ -331,7 +337,7 @@ public:
std::vector<uint32_t> startCompact(uint32_t typeId);
void finishCompact(const std::vector<uint32_t> &toHold);
- void fallbackResize(uint32_t bufferId, uint64_t sizeNeeded);
+ void fallbackResize(uint32_t bufferId, uint64_t elementsNeeded);
vespalib::GenerationHolder &getGenerationHolder() {
return _genHolder;
diff --git a/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp b/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp
index 5db3e49119f..fed720d52d2 100644
--- a/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp
@@ -75,7 +75,7 @@ FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray(ConstArrayRef array)
}
BufferState &state = *freeListList._head;
assert(state.isActive());
- assert(state.getClusterSize() == array.size());
+ assert(state.getArraySize() == array.size());
RefT ref(state.popFreeList());
EntryT *buf = _store.template getBufferEntry<EntryT>(ref.bufferId(), ref.offset() * array.size());
for (size_t i = 0; i < array.size(); ++i) {
@@ -94,7 +94,7 @@ FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray(size_t size)
}
BufferState &state = *freeListList._head;
assert(state.isActive());
- assert(state.getClusterSize() == size);
+ assert(state.getArraySize() == size);
RefT ref(state.popFreeList());
EntryT *buf = _store.template getBufferEntry<EntryT>(ref.bufferId(), ref.offset() * size);
return HandleType(ref, buf);
diff --git a/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp b/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp
index 662580ce4af..583bd865f23 100644
--- a/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp
@@ -22,10 +22,10 @@ FreeListRawAllocator<EntryT, RefT>::alloc(size_t numElems)
}
BufferState &state = *freeListList._head;
assert(state.isActive());
- assert(state.getClusterSize() == numElems);
+ assert(state.getArraySize() == numElems);
RefT ref = state.popFreeList();
- // If entry ref is not aligned we must scale the offset according to cluster size as it was divided when the entry ref was created.
- uint64_t offset = !RefT::isAlignedType ? ref.offset() * state.getClusterSize() : ref.offset();
+ // If entry ref is not aligned we must scale the offset according to array size as it was divided when the entry ref was created.
+ uint64_t offset = !RefT::isAlignedType ? ref.offset() * state.getArraySize() : ref.offset();
EntryT *entry = _store.template getBufferEntry<EntryT>(ref.bufferId(), offset);
return HandleType(ref, entry);
}
diff --git a/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp b/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp
index 8ec44bee71c..431a13f2b48 100644
--- a/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp
@@ -29,10 +29,10 @@ RawAllocator<EntryT, RefT>::alloc(size_t numElems, size_t extraElems)
// AlignedEntryRef constructor scales down offset by alignment
return HandleType(RefT(oldBufferSize, activeBufferId), buffer);
} else {
- // Must perform scaling ourselves, according to cluster size
- size_t clusterSize = state.getClusterSize();
- assert((numElems % clusterSize) == 0u);
- return HandleType(RefT(oldBufferSize / clusterSize, activeBufferId), buffer);
+ // Must perform scaling ourselves, according to array size
+ size_t arraySize = state.getArraySize();
+ assert((numElems % arraySize) == 0u);
+ return HandleType(RefT(oldBufferSize / arraySize, activeBufferId), buffer);
}
}
diff --git a/searchlib/src/vespa/searchlib/datastore/unique_store.hpp b/searchlib/src/vespa/searchlib/datastore/unique_store.hpp
index 928dbea89ed..3bbb7c0155e 100644
--- a/searchlib/src/vespa/searchlib/datastore/unique_store.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/unique_store.hpp
@@ -17,13 +17,13 @@
namespace search::datastore {
-constexpr size_t NUMCLUSTERS_FOR_NEW_UNIQUESTORE_BUFFER = 1024u;
+constexpr size_t NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER = 1024u;
constexpr float ALLOC_GROW_FACTOR = 0.2;
template <typename EntryT, typename RefT>
UniqueStore<EntryT, RefT>::UniqueStore()
: _store(),
- _typeHandler(1, 2u, RefT::offsetSize(), NUMCLUSTERS_FOR_NEW_UNIQUESTORE_BUFFER, ALLOC_GROW_FACTOR),
+ _typeHandler(1, 2u, RefT::offsetSize(), NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER, ALLOC_GROW_FACTOR),
_typeId(0),
_dict()
{
diff --git a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp
index b7fb3307de6..3f0ffafcf98 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp
@@ -14,7 +14,7 @@ typedef CompactDocumentWordsStore::Builder Builder;
namespace {
-constexpr size_t MIN_CLUSTERS = 1024u;
+constexpr size_t MIN_BUFFER_ARRAYS = 1024u;
size_t
getSerializedSize(const Builder &builder)
@@ -94,7 +94,7 @@ CompactDocumentWordsStore::Iterator::operator++()
CompactDocumentWordsStore::Store::Store()
: _store(),
_type(1,
- MIN_CLUSTERS,
+ MIN_BUFFER_ARRAYS,
RefType::offsetSize()),
_typeId(0)
{
diff --git a/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp b/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
index be8c71de7a9..9fdb23876d8 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
@@ -6,7 +6,7 @@
namespace search::memoryindex {
-constexpr size_t MIN_CLUSTERS = 1024u;
+constexpr size_t MIN_BUFFER_ARRAYS = 1024u;
using index::SchemaUtil;
@@ -78,7 +78,7 @@ FeatureStore::FeatureStore(const Schema &schema)
_d(NULL),
_fieldsParams(),
_schema(schema),
- _type(RefType::align(1u), MIN_CLUSTERS,
+ _type(RefType::align(1u), MIN_BUFFER_ARRAYS,
RefType::offsetSize() / RefType::align(1u)),
_typeId(0)
{
diff --git a/searchlib/src/vespa/searchlib/memoryindex/wordstore.cpp b/searchlib/src/vespa/searchlib/memoryindex/wordstore.cpp
index 6bf6262c336..b65fe192e58 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/wordstore.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/wordstore.cpp
@@ -5,13 +5,13 @@
namespace search::memoryindex {
-constexpr size_t MIN_CLUSTERS = 1024;
+constexpr size_t MIN_BUFFER_ARRAYS = 1024;
WordStore::WordStore()
: _store(),
_numWords(0),
_type(RefType::align(1),
- MIN_CLUSTERS,
+ MIN_BUFFER_ARRAYS,
RefType::offsetSize() / RefType::align(1)),
_typeId(0)
{
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp
index eae0f5364b8..31defbfe4d9 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp
@@ -19,7 +19,7 @@ namespace search::tensor {
namespace {
-constexpr size_t MIN_BUFFER_CLUSTERS = 1024;
+constexpr size_t MIN_BUFFER_ARRAYS = 1024;
constexpr size_t DENSE_TENSOR_ALIGNMENT = 32;
}
@@ -39,7 +39,7 @@ DenseTensorStore::TensorSizeCalc::TensorSizeCalc(const ValueType &type)
}
size_t
-DenseTensorStore::TensorSizeCalc::clusterSize() const
+DenseTensorStore::TensorSizeCalc::arraySize() const
{
size_t tensorSize = _numBoundCells * _cellSize +
_numUnboundDims * sizeof(uint32_t);
@@ -47,7 +47,7 @@ DenseTensorStore::TensorSizeCalc::clusterSize() const
}
DenseTensorStore::BufferType::BufferType(const TensorSizeCalc &tensorSizeCalc)
- : datastore::BufferType<char>(tensorSizeCalc.clusterSize(), MIN_BUFFER_CLUSTERS, RefType::offsetSize()),
+ : datastore::BufferType<char>(tensorSizeCalc.arraySize(), MIN_BUFFER_ARRAYS, RefType::offsetSize()),
_unboundDimSizesSize(tensorSizeCalc._numUnboundDims * sizeof(uint32_t))
{}
@@ -94,7 +94,7 @@ const void *
DenseTensorStore::getRawBuffer(RefType ref) const
{
return _store.getBufferEntry<char>(ref.bufferId(),
- ref.offset() * _bufferType.getClusterSize());
+ ref.offset() * _bufferType.getArraySize());
}
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h
index 55ddd2ec9e4..4008b635d85 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.h
@@ -37,7 +37,7 @@ public:
uint32_t _cellSize; // size of a cell (e.g. double => 8)
TensorSizeCalc(const ValueType &type);
- size_t clusterSize() const;
+ size_t arraySize() const;
};
class BufferType : public datastore::BufferType<char>
@@ -54,7 +54,7 @@ public:
size += alignment - 1;
return (size - (size % alignment));
}
- size_t align(size_t size) const { return align(size, _clusterSize); }
+ size_t align(size_t size) const { return align(size, _arraySize); }
};
private:
DataStoreType _concreteStore;
@@ -89,7 +89,7 @@ public:
void getTensor(EntryRef ref, vespalib::tensor::MutableDenseTensorView &tensor) const;
EntryRef setTensor(const Tensor &tensor);
// The following method is meant to be used only for unit tests.
- uint32_t getClusterSize() const { return _bufferType.getClusterSize(); }
+ uint32_t getArraySize() const { return _bufferType.getArraySize(); }
};
}
diff --git a/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp
index 6c8edfdc00d..c6cfd23f340 100644
--- a/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp
@@ -19,13 +19,13 @@ namespace search {
namespace tensor {
-constexpr size_t MIN_BUFFER_CLUSTERS = 1024;
+constexpr size_t MIN_BUFFER_ARRAYS = 1024;
GenericTensorStore::GenericTensorStore()
: TensorStore(_concreteStore),
_concreteStore(),
_bufferType(RefType::align(1),
- MIN_BUFFER_CLUSTERS,
+ MIN_BUFFER_ARRAYS,
RefType::offsetSize() / RefType::align(1))
{
_store.addType(&_bufferType);