aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-04-04 13:44:05 +0200
committerTor Egge <Tor.Egge@online.no>2023-04-04 13:44:05 +0200
commit6cbe8d589bc1d3ce62fcbaba2bb1852b9d03c4e5 (patch)
tree85faff14486de47cfd8c54000a4d435f10f0567c /vespalib/src
parent19a216715dbcf658162456894d8ad924997e7603 (diff)
Rename member variables in BufferTypeBase:
minArrays => min_entries maxArrays => max_entries numArraysForNewBuffer => num_entries_for_new_buffer
Diffstat (limited to 'vespalib/src')
-rw-r--r--vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp22
-rw-r--r--vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp20
-rw-r--r--vespalib/src/tests/datastore/datastore/datastore_test.cpp24
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreenodestore.h4
-rw-r--r--vespalib/src/vespa/vespalib/datastore/array_store.h4
-rw-r--r--vespalib/src/vespa/vespalib/datastore/array_store.hpp8
-rw-r--r--vespalib/src/vespa/vespalib/datastore/array_store_config.cpp14
-rw-r--r--vespalib/src/vespa/vespalib/datastore/array_store_config.h28
-rw-r--r--vespalib/src/vespa/vespalib/datastore/buffer_type.cpp44
-rw-r--r--vespalib/src/vespa/vespalib/datastore/buffer_type.h24
-rw-r--r--vespalib/src/vespa/vespalib/datastore/buffer_type.hpp10
-rw-r--r--vespalib/src/vespa/vespalib/datastore/datastorebase.cpp14
-rw-r--r--vespalib/src/vespa/vespalib/datastore/datastorebase.h4
-rw-r--r--vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp2
15 files changed, 112 insertions, 112 deletions
diff --git a/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp b/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp
index fcf1acd5cd3..171e7216638 100644
--- a/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp
+++ b/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp
@@ -22,32 +22,32 @@ struct Fixture
Fixture(uint32_t maxSmallArrayTypeId,
size_t hugePageSize,
size_t smallPageSize,
- size_t minNumArraysForNewBuffer)
+ size_t min_num_entries_for_new_buffer)
: cfg(ArrayStoreConfig::optimizeForHugePage(maxSmallArrayTypeId,
[](size_t type_id) noexcept { return type_id; },
hugePageSize, smallPageSize,
sizeof(int), EntryRefType::offsetSize(),
- minNumArraysForNewBuffer,
+ min_num_entries_for_new_buffer,
ALLOC_GROW_FACTOR)) { }
- void assertSpec(uint32_t type_id, uint32_t numArraysForNewBuffer) {
+ void assertSpec(uint32_t type_id, uint32_t num_entries_for_new_buffer) {
assertSpec(type_id, AllocSpec(0, EntryRefType::offsetSize(),
- numArraysForNewBuffer, ALLOC_GROW_FACTOR));
+ num_entries_for_new_buffer, ALLOC_GROW_FACTOR));
}
void assertSpec(uint32_t type_id, const AllocSpec &expSpec) {
const auto& actSpec = cfg.spec_for_type_id(type_id);
- EXPECT_EQUAL(expSpec.minArraysInBuffer, actSpec.minArraysInBuffer);
- EXPECT_EQUAL(expSpec.maxArraysInBuffer, actSpec.maxArraysInBuffer);
- EXPECT_EQUAL(expSpec.numArraysForNewBuffer, actSpec.numArraysForNewBuffer);
+ EXPECT_EQUAL(expSpec.min_entries_in_buffer, actSpec.min_entries_in_buffer);
+ EXPECT_EQUAL(expSpec.max_entries_in_buffer, actSpec.max_entries_in_buffer);
+ EXPECT_EQUAL(expSpec.num_entries_for_new_buffer, actSpec.num_entries_for_new_buffer);
EXPECT_EQUAL(expSpec.allocGrowFactor, actSpec.allocGrowFactor);
}
};
AllocSpec
-makeSpec(size_t minArraysInBuffer,
- size_t maxArraysInBuffer,
- size_t numArraysForNewBuffer)
+makeSpec(size_t min_entries_in_buffer,
+ size_t max_entries_in_buffer,
+ size_t num_entries_for_new_buffer)
{
- return AllocSpec(minArraysInBuffer, maxArraysInBuffer, numArraysForNewBuffer, ALLOC_GROW_FACTOR);
+ return AllocSpec(min_entries_in_buffer, max_entries_in_buffer, num_entries_for_new_buffer, ALLOC_GROW_FACTOR);
}
constexpr size_t KB = 1024;
diff --git a/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp b/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp
index de7d899e68a..c6824ef0e18 100644
--- a/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp
+++ b/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp
@@ -7,11 +7,11 @@ using namespace vespalib::datastore;
using IntBufferType = BufferType<int>;
constexpr uint32_t ARRAYS_SIZE(4);
-constexpr uint32_t MAX_ARRAYS(128);
-constexpr uint32_t NUM_ARRAYS_FOR_NEW_BUFFER(0);
+constexpr uint32_t MAX_ENTRIES(128);
+constexpr uint32_t NUM_ENTRIES_FOR_NEW_BUFFER(0);
struct Setup {
- uint32_t _minArrays;
+ uint32_t _min_entries;
std::atomic<ElemCount> _usedElems;
ElemCount _neededElems;
std::atomic<ElemCount> _deadElems;
@@ -19,7 +19,7 @@ struct Setup {
float _allocGrowFactor;
bool _resizing;
Setup()
- : _minArrays(0),
+ : _min_entries(0),
_usedElems(0),
_neededElems(0),
_deadElems(0),
@@ -28,7 +28,7 @@ struct Setup {
_resizing(false)
{}
Setup(const Setup& rhs) noexcept;
- Setup &minArrays(uint32_t value) { _minArrays = value; return *this; }
+ Setup &min_entries(uint32_t value) { _min_entries = value; return *this; }
Setup &used(size_t value) { _usedElems = value; return *this; }
Setup &needed(size_t value) { _neededElems = value; return *this; }
Setup &dead(size_t value) { _deadElems = value; return *this; }
@@ -37,7 +37,7 @@ struct Setup {
};
Setup::Setup(const Setup& rhs) noexcept
- : _minArrays(rhs._minArrays),
+ : _min_entries(rhs._min_entries),
_usedElems(rhs._usedElems.load(std::memory_order_relaxed)),
_neededElems(rhs._neededElems),
_deadElems(rhs._deadElems.load(std::memory_order_relaxed)),
@@ -53,7 +53,7 @@ struct Fixture {
int buffer[ARRAYS_SIZE];
Fixture(const Setup &setup_)
: setups(),
- bufferType(ARRAYS_SIZE, setup_._minArrays, MAX_ARRAYS, NUM_ARRAYS_FOR_NEW_BUFFER, setup_._allocGrowFactor),
+ bufferType(ARRAYS_SIZE, setup_._min_entries, MAX_ENTRIES, NUM_ENTRIES_FOR_NEW_BUFFER, setup_._allocGrowFactor),
buffer()
{
setups.reserve(4);
@@ -137,9 +137,9 @@ TEST("require that arrays to alloc is capped to max arrays")
TEST("require that arrays to alloc is capped to min arrays")
{
- 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_DO(assertArraysToAlloc(16, Setup().used(30 * 4).needed(4).min_entries(16)));
+ TEST_DO(assertArraysToAlloc(16, Setup().used(32 * 4).needed(4).min_entries(16)));
+ TEST_DO(assertArraysToAlloc(17, Setup().used(34 * 4).needed(4).min_entries(16)));
}
TEST("arrays to alloc considers used elements across all active buffers of same type (no resizing)")
diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp
index 7790a135768..533c06634b1 100644
--- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp
+++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp
@@ -66,10 +66,10 @@ class GrowStore
BufferType<DataType> _type;
uint32_t _typeId;
public:
- GrowStore(size_t arraySize, size_t minArrays, size_t maxArrays, size_t numArraysForNewBuffer)
+ GrowStore(size_t arraySize, size_t min_entries, size_t max_entries, size_t num_entries_for_new_buffer)
: _store(),
- _firstType(1, 1, maxArrays, 0, ALLOC_GROW_FACTOR),
- _type(arraySize, minArrays, maxArrays, numArraysForNewBuffer, ALLOC_GROW_FACTOR),
+ _firstType(1, 1, max_entries, 0, ALLOC_GROW_FACTOR),
+ _type(arraySize, min_entries, max_entries, num_entries_for_new_buffer, ALLOC_GROW_FACTOR),
_typeId(0)
{
(void) _store.addType(&_firstType);
@@ -529,11 +529,11 @@ namespace {
void assertGrowStats(GrowthStats expSizes,
GrowthStats expFirstBufSizes,
size_t expInitMemUsage,
- size_t minArrays, size_t numArraysForNewBuffer, size_t maxArrays = 128)
+ size_t min_entries, size_t num_entries_for_new_buffer, size_t max_entries = 128)
{
- 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());
+ EXPECT_EQ(expSizes, IntGrowStore(1, min_entries, max_entries, num_entries_for_new_buffer).getGrowthStats(expSizes.size()));
+ EXPECT_EQ(expFirstBufSizes, IntGrowStore(1, min_entries, max_entries, num_entries_for_new_buffer).getFirstBufGrowStats());
+ EXPECT_EQ(expInitMemUsage, IntGrowStore(1, min_entries, max_entries, num_entries_for_new_buffer).getMemoryUsage().allocatedBytes());
}
}
@@ -574,10 +574,10 @@ namespace {
template <typename DataType>
void assertGrowStats(GrowthStats expSizes, uint32_t arraySize)
{
- uint32_t minArrays = 2048;
- uint32_t maxArrays = RefType15::offsetSize();
- uint32_t numArraysForNewBuffer = 2048;
- GrowStore<DataType, RefType15> store(arraySize, minArrays, maxArrays, numArraysForNewBuffer);
+ uint32_t min_entries = 2048;
+ uint32_t max_entries = RefType15::offsetSize();
+ uint32_t num_entries_for_new_buffer = 2048;
+ GrowStore<DataType, RefType15> store(arraySize, min_entries, max_entries, num_entries_for_new_buffer);
EXPECT_EQ(expSizes, store.getGrowthStats(expSizes.size()));
}
@@ -594,7 +594,7 @@ TEST(DataStoreTest, require_that_offset_in_EntryRefT_is_within_bounds_when_alloc
* 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: maxArrays * arraySize * elementSize.
+ * The max bytes to alloc is: max_entries * arraySize * elementSize.
*/
assertGrowStats<uint8_t>({8192,16384,16384,65536,65536,98304,98304,98304,98304,98304,98304,98304}, 3);
assertGrowStats<uint8_t>({16384,16384,65536,65536,131072,131072,163840,163840,163840,163840,163840,163840}, 5);
diff --git a/vespalib/src/vespa/vespalib/btree/btreenodestore.h b/vespalib/src/vespa/vespalib/btree/btreenodestore.h
index c59092bf75c..77ebfc96546 100644
--- a/vespalib/src/vespa/vespalib/btree/btreenodestore.h
+++ b/vespalib/src/vespa/vespalib/btree/btreenodestore.h
@@ -32,8 +32,8 @@ class BTreeNodeBufferType : public datastore::BufferType<EntryType, FrozenBtreeN
using ElemCount = typename ParentType::ElemCount;
using CleanContext = typename ParentType::CleanContext;
public:
- BTreeNodeBufferType(uint32_t minArrays, uint32_t maxArrays)
- : ParentType(1, minArrays, maxArrays)
+ BTreeNodeBufferType(uint32_t min_entries, uint32_t max_entries)
+ : ParentType(1, min_entries, max_entries)
{ }
void initializeReservedElements(void *buffer, ElemCount reservedElements) override;
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.h b/vespalib/src/vespa/vespalib/datastore/array_store.h
index 2093b7ab923..809ac10f6e3 100644
--- a/vespalib/src/vespa/vespalib/datastore/array_store.h
+++ b/vespalib/src/vespa/vespalib/datastore/array_store.h
@@ -150,14 +150,14 @@ public:
static ArrayStoreConfig optimizedConfigForHugePage(uint32_t maxSmallArrayTypeId,
size_t hugePageSize,
size_t smallPageSize,
- size_t minNumArraysForNewBuffer,
+ size_t min_num_entries_for_new_buffer,
float allocGrowFactor);
static ArrayStoreConfig optimizedConfigForHugePage(uint32_t maxSmallArrayTypeId,
const TypeMapper& mapper,
size_t hugePageSize,
size_t smallPageSize,
- size_t minNumArraysForNewBuffer,
+ size_t min_num_entries_for_new_buffer,
float allocGrowFactor);
};
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.hpp b/vespalib/src/vespa/vespalib/datastore/array_store.hpp
index e55e7bfc15f..40d750b399d 100644
--- a/vespalib/src/vespa/vespalib/datastore/array_store.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/array_store.hpp
@@ -208,7 +208,7 @@ ArrayStoreConfig
ArrayStore<ElemT, RefT, TypeMapperT>::optimizedConfigForHugePage(uint32_t maxSmallArrayTypeId,
size_t hugePageSize,
size_t smallPageSize,
- size_t minNumArraysForNewBuffer,
+ size_t min_num_entries_for_new_buffer,
float allocGrowFactor)
{
TypeMapper mapper;
@@ -216,7 +216,7 @@ ArrayStore<ElemT, RefT, TypeMapperT>::optimizedConfigForHugePage(uint32_t maxSma
mapper,
hugePageSize,
smallPageSize,
- minNumArraysForNewBuffer,
+ min_num_entries_for_new_buffer,
allocGrowFactor);
}
@@ -226,7 +226,7 @@ ArrayStore<ElemT, RefT, TypeMapperT>::optimizedConfigForHugePage(uint32_t maxSma
const TypeMapper& mapper,
size_t hugePageSize,
size_t smallPageSize,
- size_t minNumArraysForNewBuffer,
+ size_t min_num_entries_for_new_buffer,
float allocGrowFactor)
{
return ArrayStoreConfig::optimizeForHugePage(mapper.get_max_small_array_type_id(maxSmallArrayTypeId),
@@ -235,7 +235,7 @@ ArrayStore<ElemT, RefT, TypeMapperT>::optimizedConfigForHugePage(uint32_t maxSma
smallPageSize,
sizeof(ElemT),
RefT::offsetSize(),
- minNumArraysForNewBuffer,
+ min_num_entries_for_new_buffer,
allocGrowFactor);
}
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store_config.cpp b/vespalib/src/vespa/vespalib/datastore/array_store_config.cpp
index d5587841745..1df9354cd6c 100644
--- a/vespalib/src/vespa/vespalib/datastore/array_store_config.cpp
+++ b/vespalib/src/vespa/vespalib/datastore/array_store_config.cpp
@@ -49,19 +49,19 @@ ArrayStoreConfig::optimizeForHugePage(uint32_t maxSmallArrayTypeId,
std::function<size_t(uint32_t)> type_id_to_array_size,
size_t hugePageSize,
size_t smallPageSize,
- size_t entrySize,
+ size_t elem_size,
size_t maxEntryRefOffset,
- size_t minNumArraysForNewBuffer,
+ size_t min_num_entries_for_new_buffer,
float allocGrowFactor)
{
AllocSpecVector allocSpecs;
- allocSpecs.emplace_back(0, maxEntryRefOffset, minNumArraysForNewBuffer, allocGrowFactor); // large array spec;
+ allocSpecs.emplace_back(0, maxEntryRefOffset, min_num_entries_for_new_buffer, allocGrowFactor); // large array spec;
for (uint32_t type_id = 1; type_id <= maxSmallArrayTypeId; ++type_id) {
size_t arraySize = type_id_to_array_size(type_id);
- size_t numArraysForNewBuffer = hugePageSize / (entrySize * arraySize);
- numArraysForNewBuffer = capToLimits(numArraysForNewBuffer, minNumArraysForNewBuffer, maxEntryRefOffset);
- numArraysForNewBuffer = alignToSmallPageSize(numArraysForNewBuffer, minNumArraysForNewBuffer, smallPageSize);
- allocSpecs.emplace_back(0, maxEntryRefOffset, numArraysForNewBuffer, allocGrowFactor);
+ size_t num_entries_for_new_buffer = hugePageSize / (elem_size * arraySize);
+ num_entries_for_new_buffer = capToLimits(num_entries_for_new_buffer, min_num_entries_for_new_buffer, maxEntryRefOffset);
+ num_entries_for_new_buffer = alignToSmallPageSize(num_entries_for_new_buffer, min_num_entries_for_new_buffer, smallPageSize);
+ allocSpecs.emplace_back(0, maxEntryRefOffset, num_entries_for_new_buffer, allocGrowFactor);
}
return ArrayStoreConfig(allocSpecs);
}
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store_config.h b/vespalib/src/vespa/vespalib/datastore/array_store_config.h
index a326c00d042..cae241dba10 100644
--- a/vespalib/src/vespa/vespalib/datastore/array_store_config.h
+++ b/vespalib/src/vespa/vespalib/datastore/array_store_config.h
@@ -19,21 +19,21 @@ public:
* Specification of buffer allocation strategy for arrays of a given size.
*/
struct AllocSpec {
- // Minimum number of arrays to allocate in a buffer.
- size_t minArraysInBuffer;
- // Maximum number of arrays to allocate in a buffer.
- size_t maxArraysInBuffer;
- // Number of arrays needed before allocating a new buffer instead of just resizing the first one.
- size_t numArraysForNewBuffer;
+ // Minimum number of entries to allocate in a buffer.
+ size_t min_entries_in_buffer;
+ // Maximum number of entries to allocate in a buffer.
+ size_t max_entries_in_buffer;
+ // Number of entries needed before allocating a new buffer instead of just resizing the first one.
+ size_t num_entries_for_new_buffer;
// Grow factor used when allocating a new buffer.
float allocGrowFactor;
- AllocSpec(size_t minArraysInBuffer_,
- size_t maxArraysInBuffer_,
- size_t numArraysForNewBuffer_,
+ AllocSpec(size_t min_entries_in_buffer_,
+ size_t max_entries_in_buffer_,
+ size_t num_entries_for_new_buffer_,
float allocGrowFactor_) noexcept
- : minArraysInBuffer(minArraysInBuffer_),
- maxArraysInBuffer(maxArraysInBuffer_),
- numArraysForNewBuffer(numArraysForNewBuffer_),
+ : min_entries_in_buffer(min_entries_in_buffer_),
+ max_entries_in_buffer(max_entries_in_buffer_),
+ num_entries_for_new_buffer(num_entries_for_new_buffer_),
allocGrowFactor(allocGrowFactor_) {}
};
@@ -76,9 +76,9 @@ public:
std::function<size_t(uint32_t)> type_id_to_array_size,
size_t hugePageSize,
size_t smallPageSize,
- size_t entrySize,
+ size_t elem_size,
size_t maxEntryRefOffset,
- size_t minNumArraysForNewBuffer,
+ size_t min_num_entries_for_new_buffer,
float allocGrowFactor);
};
diff --git a/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp b/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp
index 4a9ba2d33a8..5dbd24de271 100644
--- a/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp
+++ b/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp
@@ -27,14 +27,14 @@ BufferTypeBase::CleanContext::extraBytesCleaned(size_t value)
}
BufferTypeBase::BufferTypeBase(uint32_t arraySize,
- uint32_t minArrays,
- uint32_t maxArrays,
- uint32_t numArraysForNewBuffer,
+ uint32_t min_entries,
+ uint32_t max_entries,
+ uint32_t num_entries_for_new_buffer,
float allocGrowFactor) noexcept
: _arraySize(arraySize),
- _minArrays(std::min(minArrays, maxArrays)),
- _maxArrays(maxArrays),
- _numArraysForNewBuffer(std::min(numArraysForNewBuffer, maxArrays)),
+ _min_entries(std::min(min_entries, max_entries)),
+ _max_entries(max_entries),
+ _num_entries_for_new_buffer(std::min(num_entries_for_new_buffer, max_entries)),
_allocGrowFactor(allocGrowFactor),
_holdBuffers(0),
_holdUsedElems(0),
@@ -44,9 +44,9 @@ BufferTypeBase::BufferTypeBase(uint32_t arraySize,
}
BufferTypeBase::BufferTypeBase(uint32_t arraySize,
- uint32_t minArrays,
- uint32_t maxArrays) noexcept
- : BufferTypeBase(arraySize, minArrays, maxArrays, 0u, DEFAULT_ALLOC_GROW_FACTOR)
+ uint32_t min_entries,
+ uint32_t max_entries) noexcept
+ : BufferTypeBase(arraySize, min_entries, max_entries, 0u, DEFAULT_ALLOC_GROW_FACTOR)
{
}
@@ -115,11 +115,11 @@ BufferTypeBase::get_memory_allocator() const
}
void
-BufferTypeBase::clampMaxArrays(uint32_t maxArrays)
+BufferTypeBase::clampMaxArrays(uint32_t max_entries)
{
- _maxArrays = std::min(_maxArrays, maxArrays);
- _minArrays = std::min(_minArrays, _maxArrays);
- _numArraysForNewBuffer = std::min(_numArraysForNewBuffer, _maxArrays);
+ _max_entries = std::min(_max_entries, max_entries);
+ _min_entries = std::min(_min_entries, _max_entries);
+ _num_entries_for_new_buffer = std::min(_num_entries_for_new_buffer, _max_entries);
}
size_t
@@ -143,14 +143,14 @@ BufferTypeBase::calcArraysToAlloc(uint32_t bufferId, ElemCount elemsNeeded, bool
size_t growArrays = (liveArrays * _allocGrowFactor);
size_t usedArrays = last_bc.used_elems / _arraySize;
size_t wantedArrays = std::max((resizing ? usedArrays : 0u) + growArrays,
- static_cast<size_t>(_minArrays));
+ static_cast<size_t>(_min_entries));
size_t result = wantedArrays;
if (result < neededArrays) {
result = neededArrays;
}
- if (result > _maxArrays) {
- result = _maxArrays;
+ if (result > _max_entries) {
+ result = _max_entries;
}
if (result < neededArrays) {
vespalib::asciistream s;
@@ -160,7 +160,7 @@ BufferTypeBase::calcArraysToAlloc(uint32_t bufferId, ElemCount elemsNeeded, bool
",resizing=" << (resizing ? "true" : "false") << ")" <<
" wantedArrays=" << wantedArrays <<
", _arraySize=" << _arraySize <<
- ", _maxArrays=" << _maxArrays <<
+ ", _max_entries=" << _max_entries <<
", reservedElems=" << reservedElems <<
", liveArrays=" << liveArrays <<
", growArrays=" << growArrays <<
@@ -177,13 +177,13 @@ uint32_t
BufferTypeBase::get_scaled_num_arrays_for_new_buffer() const
{
uint32_t active_buffers_count = get_active_buffers_count();
- if (active_buffers_count <= 1u || _numArraysForNewBuffer == 0u) {
- return _numArraysForNewBuffer;
+ if (active_buffers_count <= 1u || _num_entries_for_new_buffer == 0u) {
+ return _num_entries_for_new_buffer;
}
double scale_factor = std::pow(1.0 + _allocGrowFactor, active_buffers_count - 1);
- double scaled_result = _numArraysForNewBuffer * scale_factor;
- if (scaled_result >= _maxArrays) {
- return _maxArrays;
+ double scaled_result = _num_entries_for_new_buffer * scale_factor;
+ if (scaled_result >= _max_entries) {
+ return _max_entries;
}
return scaled_result;
}
diff --git a/vespalib/src/vespa/vespalib/datastore/buffer_type.h b/vespalib/src/vespa/vespalib/datastore/buffer_type.h
index 625ad147d36..831acdaa830 100644
--- a/vespalib/src/vespa/vespalib/datastore/buffer_type.h
+++ b/vespalib/src/vespa/vespalib/datastore/buffer_type.h
@@ -39,9 +39,9 @@ public:
BufferTypeBase & operator=(const BufferTypeBase &rhs) = delete;
BufferTypeBase(BufferTypeBase &&rhs) noexcept = default;
BufferTypeBase & operator=(BufferTypeBase &&rhs) noexcept = default;
- BufferTypeBase(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays) noexcept;
- BufferTypeBase(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays,
- uint32_t numArraysForNewBuffer, float allocGrowFactor) noexcept;
+ BufferTypeBase(uint32_t arraySize, uint32_t min_entries, uint32_t max_entries) noexcept;
+ BufferTypeBase(uint32_t arraySize, uint32_t min_entries, uint32_t max_entries,
+ uint32_t num_entries_for_new_buffer, float allocGrowFactor) noexcept;
virtual ~BufferTypeBase();
virtual void destroyElements(void *buffer, ElemCount numElems) = 0;
virtual void fallbackCopy(void *newBuffer, const void *oldBuffer, ElemCount numElems) = 0;
@@ -71,13 +71,13 @@ public:
*/
virtual size_t calcArraysToAlloc(uint32_t bufferId, ElemCount elementsNeeded, bool resizing) const;
- void clampMaxArrays(uint32_t maxArrays);
+ void clampMaxArrays(uint32_t max_entries);
uint32_t get_active_buffers_count() const { return _active_buffers.size(); }
const std::vector<uint32_t>& get_active_buffers() const noexcept { return _active_buffers; }
- size_t getMaxArrays() const { return _maxArrays; }
+ size_t getMaxArrays() const { return _max_entries; }
uint32_t get_scaled_num_arrays_for_new_buffer() const;
- uint32_t get_num_arrays_for_new_buffer() const noexcept { return _numArraysForNewBuffer; }
+ uint32_t get_num_arrays_for_new_buffer() const noexcept { return _num_entries_for_new_buffer; }
protected:
struct BufferCounts {
@@ -114,10 +114,10 @@ protected:
};
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
+ uint32_t _min_entries; // Minimum number of arrays to allocate in a buffer
+ uint32_t _max_entries; // 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;
+ uint32_t _num_entries_for_new_buffer;
float _allocGrowFactor;
uint32_t _holdBuffers;
size_t _holdUsedElems; // Number of used elements in all held buffers for this type.
@@ -143,9 +143,9 @@ public:
BufferType & operator=(const BufferType &rhs) = delete;
BufferType(BufferType && rhs) noexcept = default;
BufferType & operator=(BufferType && rhs) noexcept = default;
- BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays) noexcept;
- BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays,
- uint32_t numArraysForNewBuffer, float allocGrowFactor) noexcept;
+ BufferType(uint32_t arraySize, uint32_t min_entries, uint32_t max_entries) noexcept;
+ BufferType(uint32_t arraySize, uint32_t min_entries, uint32_t max_entries,
+ uint32_t num_entries_for_new_buffer, float allocGrowFactor) noexcept;
~BufferType() override;
void destroyElements(void *buffer, ElemCount numElems) override;
void fallbackCopy(void *newBuffer, const void *oldBuffer, ElemCount numElems) override;
diff --git a/vespalib/src/vespa/vespalib/datastore/buffer_type.hpp b/vespalib/src/vespa/vespalib/datastore/buffer_type.hpp
index 504194e1791..304b558dac2 100644
--- a/vespalib/src/vespa/vespalib/datastore/buffer_type.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/buffer_type.hpp
@@ -7,14 +7,14 @@
namespace vespalib::datastore {
template <typename ElemT, typename EmptyT>
-BufferType<ElemT, EmptyT>::BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays) noexcept
- : BufferTypeBase(arraySize, minArrays, maxArrays)
+BufferType<ElemT, EmptyT>::BufferType(uint32_t arraySize, uint32_t min_entries, uint32_t max_entries) noexcept
+ : BufferTypeBase(arraySize, min_entries, max_entries)
{ }
template <typename ElemT, typename EmptyT>
-BufferType<ElemT, EmptyT>::BufferType(uint32_t arraySize, uint32_t minArrays, uint32_t maxArrays,
- uint32_t numArraysForNewBuffer, float allocGrowFactor) noexcept
- : BufferTypeBase(arraySize, minArrays, maxArrays, numArraysForNewBuffer, allocGrowFactor)
+BufferType<ElemT, EmptyT>::BufferType(uint32_t arraySize, uint32_t min_entries, uint32_t max_entries,
+ uint32_t num_entries_for_new_buffer, float allocGrowFactor) noexcept
+ : BufferTypeBase(arraySize, min_entries, max_entries, num_entries_for_new_buffer, allocGrowFactor)
{ }
template <typename ElemT, typename EmptyT>
diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp
index a7115a1ddcf..3c44712505a 100644
--- a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp
+++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp
@@ -80,7 +80,7 @@ public:
}
};
-DataStoreBase::DataStoreBase(uint32_t numBuffers, uint32_t offset_bits, size_t maxArrays)
+DataStoreBase::DataStoreBase(uint32_t numBuffers, uint32_t offset_bits, size_t max_entries)
: _entry_ref_hold_list(),
_buffers(numBuffers),
_primary_buffer_ids(),
@@ -89,7 +89,7 @@ DataStoreBase::DataStoreBase(uint32_t numBuffers, uint32_t offset_bits, size_t m
_free_lists(),
_compaction_count(0u),
_genHolder(),
- _maxArrays(maxArrays),
+ _max_entries(max_entries),
_bufferIdLimit(0u),
_hold_buffer_count(0u),
_offset_bits(offset_bits),
@@ -185,8 +185,8 @@ DataStoreBase::switch_or_grow_primary_buffer(uint32_t typeId, size_t entries_nee
{
auto typeHandler = _typeHandlers[typeId];
uint32_t arraySize = typeHandler->getArraySize();
- size_t numArraysForNewBuffer = typeHandler->get_scaled_num_arrays_for_new_buffer();
- size_t numElemsForNewBuffer = numArraysForNewBuffer * arraySize;
+ size_t num_entries_for_new_buffer = typeHandler->get_scaled_num_arrays_for_new_buffer();
+ size_t numElemsForNewBuffer = num_entries_for_new_buffer * arraySize;
uint32_t bufferId = primary_buffer_id(typeId);
if (entries_needed * arraySize + getBufferState(bufferId).size() >= numElemsForNewBuffer) {
if (consider_grow_active_buffer(typeId, entries_needed)) {
@@ -219,7 +219,7 @@ DataStoreBase::addType(BufferTypeBase *typeHandler)
{
uint32_t typeId = _primary_buffer_ids.size();
assert(typeId == _typeHandlers.size());
- typeHandler->clampMaxArrays(_maxArrays);
+ typeHandler->clampMaxArrays(_max_entries);
_primary_buffer_ids.push_back(0);
_typeHandlers.push_back(typeHandler);
_free_lists.emplace_back();
@@ -375,12 +375,12 @@ DataStoreBase::getAddressSpaceUsage() const
uint32_t buffer_id_limit = get_bufferid_limit_acquire();
size_t usedArrays = 0;
size_t deadArrays = 0;
- size_t limitArrays = size_t(_maxArrays) * (getMaxNumBuffers() - buffer_id_limit);
+ size_t limitArrays = size_t(_max_entries) * (getMaxNumBuffers() - buffer_id_limit);
for (uint32_t bufferId = 0; bufferId < buffer_id_limit; ++bufferId) {
const BufferState * bState = _buffers[bufferId].get_state_acquire();
assert(bState != nullptr);
if (bState->isFree()) {
- limitArrays += _maxArrays;
+ limitArrays += _max_entries;
} else if (bState->isActive()) {
uint32_t arraySize = bState->getArraySize();
usedArrays += bState->size() / arraySize;
diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.h b/vespalib/src/vespa/vespalib/datastore/datastorebase.h
index a2ae5bb9965..8c5d5b1aee4 100644
--- a/vespalib/src/vespa/vespalib/datastore/datastorebase.h
+++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.h
@@ -185,7 +185,7 @@ public:
virtual void reclaim_entry_refs(generation_t oldest_used_gen) = 0;
protected:
- DataStoreBase(uint32_t numBuffers, uint32_t offset_bits, size_t maxArrays);
+ DataStoreBase(uint32_t numBuffers, uint32_t offset_bits, size_t max_entries);
virtual ~DataStoreBase();
void* getBuffer(uint32_t bufferId) { return _buffers[bufferId].get_buffer_relaxed(); }
@@ -270,7 +270,7 @@ private:
std::vector<FreeList> _free_lists;
mutable std::atomic<uint64_t> _compaction_count;
vespalib::GenerationHolder _genHolder;
- const uint32_t _maxArrays;
+ const uint32_t _max_entries;
std::atomic<uint32_t> _bufferIdLimit;
uint32_t _hold_buffer_count;
const uint8_t _offset_bits;
diff --git a/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp b/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp
index 102c13ef1cc..0165efd8f32 100644
--- a/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp
@@ -9,7 +9,7 @@ namespace vespalib::datastore {
template <typename ElemT>
LargeArrayBufferType<ElemT>::LargeArrayBufferType(const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator) noexcept
- : BufferType<Array<ElemT>>(1u, spec.minArraysInBuffer, spec.maxArraysInBuffer, spec.numArraysForNewBuffer, spec.allocGrowFactor),
+ : BufferType<Array<ElemT>>(1u, spec.min_entries_in_buffer, spec.max_entries_in_buffer, spec.num_entries_for_new_buffer, spec.allocGrowFactor),
_memory_allocator(std::move(memory_allocator))
{
}
diff --git a/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp b/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp
index b38d8f84275..c9033936bd6 100644
--- a/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp
@@ -8,7 +8,7 @@ namespace vespalib::datastore {
template <typename ElemT>
SmallArrayBufferType<ElemT>::SmallArrayBufferType(uint32_t array_size, const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator) noexcept
- : BufferType<ElemT>(array_size, spec.minArraysInBuffer, spec.maxArraysInBuffer, spec.numArraysForNewBuffer, spec.allocGrowFactor),
+ : BufferType<ElemT>(array_size, spec.min_entries_in_buffer, spec.max_entries_in_buffer, spec.num_entries_for_new_buffer, spec.allocGrowFactor),
_memory_allocator(std::move(memory_allocator))
{
}