MCPcopy Create free account
hub / github.com/apache/impala / PrepareToAllocateBuffer

Method PrepareToAllocateBuffer

be/src/runtime/bufferpool/buffer-pool.cc:603–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603Status BufferPool::Client::PrepareToAllocateBuffer(
604 int64_t len, bool reserved, bool* success) {
605 if (success != nullptr) *success = false;
606 // Don't need to hold the client's 'lock_' yet because 'reservation_' operations are
607 // threadsafe.
608 if (reserved) {
609 // The client must have already reserved the memory.
610 reservation_.AllocateFrom(len);
611 } else {
612 DCHECK(success != nullptr);
613 // The client may not have reserved the memory.
614 if (!reservation_.IncreaseReservationToFitAndAllocate(len)) return Status::OK();
615 }
616
617 {
618 unique_lock<mutex> lock(lock_);
619 // Clean enough pages to allow allocation to proceed without violating our eviction
620 // policy.
621 Status status = CleanPages(&lock, len);
622 if (!status.ok()) {
623 // Reverse the allocation.
624 reservation_.ReleaseTo(len);
625 return status;
626 }
627 buffers_allocated_bytes_ += len;
628 DCHECK_CONSISTENCY();
629 }
630 if (success != nullptr) *success = true;
631 return Status::OK();
632}
633
634Status BufferPool::Client::DecreaseReservationTo(
635 int64_t max_decrease, int64_t target_bytes) {

Callers 2

AllocateBufferMethod · 0.80

Calls 5

OKFunction · 0.85
AllocateFromMethod · 0.80
ReleaseToMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected