|
|
static constexpr idx_t | BATCH_SIZE = 128 |
|
static constexpr idx_t | FREE_THRESHOLD = BATCH_SIZE * 2 |
◆ BlockAllocatorThreadLocalState()
| duckdb::BlockAllocatorThreadLocalState::BlockAllocatorThreadLocalState |
( |
const BlockAllocator & | block_allocator_p | ) |
|
|
inlineexplicit |
386458 {
386459 Initialize(block_allocator_p);
386460 }
◆ ~BlockAllocatorThreadLocalState()
| duckdb::BlockAllocatorThreadLocalState::~BlockAllocatorThreadLocalState |
( |
| ) |
|
|
inline |
386461 {
386462 Clear();
386463 }
◆ TryInitialize()
| void duckdb::BlockAllocatorThreadLocalState::TryInitialize |
( |
const BlockAllocator & | block_allocator_p | ) |
|
|
inline |
386466 {
386467
386468 if (cached_uuid != block_allocator_p.uuid) {
386469 Initialize(block_allocator_p);
386470 }
386471 }
◆ Allocate()
| data_ptr_t duckdb::BlockAllocatorThreadLocalState::Allocate |
( |
| ) |
|
|
inline |
386473 {
386474 auto pointer = TryAllocateFromLocal();
386475 if (pointer) {
386476 return pointer;
386477 }
386478
386479
386480 if (TryGetBatch(touched, *block_allocator->touched) || TryGetBatch(untouched, *block_allocator->untouched)) {
386481
386482 pointer = TryAllocateFromLocal();
386483 D_ASSERT(pointer);
386484 return pointer;
386485 }
386486
386487
386488 return block_allocator->allocator.AllocateData(block_allocator->block_size);
386489 }
◆ Free()
| void duckdb::BlockAllocatorThreadLocalState::Free |
( |
const data_ptr_t | pointer | ) |
|
|
inline |
386491 {
386492 touched.push_back(block_allocator->GetBlockID(pointer));
386493 if (touched.size() < FREE_THRESHOLD) {
386494 return;
386495 }
386496
386497
386498 std::sort(touched.begin(), touched.end());
386499 block_allocator->touched->q.enqueue_bulk(touched.end() - BATCH_SIZE, BATCH_SIZE);
386500 touched.resize(touched.size() - BATCH_SIZE);
386501 }
◆ Clear()
| void duckdb::BlockAllocatorThreadLocalState::Clear |
( |
| ) |
|
|
inline |
386503 {
386504
386505 if (!touched.empty()) {
386506 block_allocator->touched->q.enqueue_bulk(touched.begin(), touched.size());
386507 touched.clear();
386508 }
386509 if (!untouched.empty()) {
386510 block_allocator->untouched->q.enqueue_bulk(untouched.begin(), untouched.size());
386511 untouched.clear();
386512 }
386513 }
◆ Initialize()
| void duckdb::BlockAllocatorThreadLocalState::Initialize |
( |
const BlockAllocator & | block_allocator_p | ) |
|
|
inlineprivate |
386516 {
386517 cached_uuid = block_allocator_p.uuid;
386518 block_allocator = block_allocator_p;
386519 untouched.clear();
386520 touched.clear();
386521 untouched.reserve(BATCH_SIZE);
386522 touched.reserve(FREE_THRESHOLD);
386523 }
◆ TryAllocateFromLocal()
| data_ptr_t duckdb::BlockAllocatorThreadLocalState::TryAllocateFromLocal |
( |
| ) |
|
|
inlineprivate |
386525 {
386526 if (!touched.empty()) {
386527 const auto pointer = block_allocator->GetPointer(touched.back());
386528 touched.pop_back();
386529 return pointer;
386530 }
386531 if (!untouched.empty()) {
386532 const auto pointer = block_allocator->GetPointer(untouched.back());
386533 untouched.pop_back();
386534 OnFirstAllocation(pointer, block_allocator->block_size);
386535 return pointer;
386536 }
386537 return nullptr;
386538 }
◆ TryGetBatch()
386540 {
386541 D_ASSERT(local.empty());
386542 local.resize(BATCH_SIZE);
386543 const auto size = global.q.try_dequeue_bulk(local.begin(), BATCH_SIZE);
386544 local.resize(size);
386545 std::sort(local.begin(), local.end());
386546 return !local.empty();
386547 }
GOpaque< Size > size(const GMat &src)
The documentation for this class was generated from the following file: