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

Method addRootPool

bolt/common/memory/Memory.cpp:346–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346std::shared_ptr<MemoryPool> MemoryManager::addRootPool(
347 const std::string& name,
348 int64_t maxCapacity,
349 std::unique_ptr<MemoryReclaimer> reclaimer,
350 const std::optional<MemoryPool::DebugOptions>& poolDebugOpts) {
351 std::string poolName = name;
352 if (poolName.empty()) {
353 static std::atomic<int64_t> poolId{0};
354 poolName = fmt::format("default_root_{}", poolId++);
355 }
356
357 MemoryPool::Options options;
358 options.alignment = alignment_;
359 options.maxCapacity = maxCapacity;
360 options.trackUsage = true;
361 options.coreOnAllocationFailureEnabled = coreOnAllocationFailureEnabled_;
362 options.getPreferredSize = getPreferredSize_;
363 options.debugOptions = poolDebugOpts;
364
365 options.poolRegex = poolRegex_;
366 options.singleAllocationThreshold = singleAllocationThreshold_;
367 options.accumulativeAllocationThreshold = accumulativeAllocationThreshold_;
368 options.enableDynamicMemoryQuotaManager = enableDynamicMemoryQuotaManager_;
369
370 auto pool = createRootPool(poolName, reclaimer, options);
371 if (!disableMemoryPoolTracking_) {
372 try {
373 std::unique_lock guard{mutex_};
374 if (pools_.find(poolName) != pools_.end()) {
375 BOLT_FAIL("Duplicate root pool name found: {}", poolName);
376 }
377 pools_.emplace(poolName, pool);
378 } catch (const BoltRuntimeError&) {
379 arbitrator_->removePool(pool.get());
380 throw;
381 }
382 }
383 // NOTE: we need to set destruction callback at the end to avoid potential
384 // deadlock or failure because of duplicate memory pool name or unexpected
385 // failure to add memory pool to the arbitrator.
386 pool->setDestructionCallback(poolDestructionCb_);
387 return pool;
388}
389
390std::shared_ptr<MemoryPool> MemoryManager::addLeafPool(
391 const std::string& name,

Callers 15

VectorTestBase.hFile · 0.80
initPoolMethod · 0.80
TEST_FFunction · 0.80
TEST_PFunction · 0.80
TEST_FFunction · 0.80
runBenchmarkFunction · 0.80
testDataTypeWriterFunction · 0.80
TEST_FFunction · 0.80
testMapWriterFunction · 0.80
testMapWriterRowFunction · 0.80
testMapWriterStatsFunction · 0.80
runTestMethod · 0.80

Calls 7

emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emplaceMethod · 0.45
removePoolMethod · 0.45
getMethod · 0.45

Tested by 15

TEST_FFunction · 0.64
TEST_PFunction · 0.64
TEST_FFunction · 0.64
runBenchmarkFunction · 0.64
testDataTypeWriterFunction · 0.64
TEST_FFunction · 0.64
testMapWriterFunction · 0.64
testMapWriterRowFunction · 0.64
testMapWriterStatsFunction · 0.64
runTestMethod · 0.64
runTestMethod · 0.64