MCPcopy Create free account
hub / github.com/bytedance/bolt / allocateContiguous

Method allocateContiguous

bolt/common/memory/MemoryPool.cpp:777–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775 CHECK_AND_INC_MEM_OP_STATS(this, Allocs);
776 if (!out.empty()) {
777 INC_MEM_OP_STATS(Frees);
778 }
779 BOLT_CHECK_GT(numPages, 0);
780 RECORD_FREE(out);
781 if (!allocator_->allocateContiguous(
782 numPages,
783 nullptr,
784 out,
785 [this](uint64_t allocBytes, bool preAlloc) {
786 if (preAlloc) {
787 reserve(allocBytes);
788 } else {
789 release(allocBytes);
790 }
791 },
792 maxPages)) {
793 BOLT_CHECK(out.empty());
794 handleAllocationFailure(fmt::format(
795 "{} failed with {} pages from {} {}",
796 __FUNCTION__,
797 numPages,
798 toString(),
799 allocator_->getAndClearFailureMessage()));
800 }
801 RECORD_ALLOC(out);
802 BOLT_CHECK(!out.empty());
803 BOLT_CHECK_NULL(out.pool());
804 out.setPool(this);
805}
806
807void MemoryPoolImpl::freeContiguous(ContiguousAllocation& allocation) {
808 CHECK_AND_INC_MEM_OP_STATS(this, Frees);
809 const int64_t bytesToFree = allocation.size();
810 RECORD_FREE(allocation);
811 allocator_->freeContiguous(allocation);
812 BOLT_CHECK(allocation.empty());
813 release(bytesToFree);
814}

Callers 6

allocateTablesMethod · 0.45
setHashModeMethod · 0.45
newRunImplMethod · 0.45
newRangeMethod · 0.45
loadLoopMethod · 0.45
TEST_FFunction · 0.45

Calls 5

toStringFunction · 0.50
emptyMethod · 0.45
poolMethod · 0.45
setPoolMethod · 0.45

Tested by 2

loadLoopMethod · 0.36
TEST_FFunction · 0.36