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

Method initialize

bolt/common/caching/AsyncDataCache.cpp:114–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void AsyncDataCacheEntry::initialize(FileCacheKey key) {
115 BOLT_CHECK(isExclusive());
116 setSsdFile(nullptr, 0);
117 key_ = std::move(key);
118 auto* cache = shard_->cache();
119 ClockTimer t(shard_->allocClocks());
120 if (size_ < AsyncDataCacheEntry::kTinyDataSize) {
121 tinyData_.resize(size_);
122 tinyData_.shrink_to_fit();
123 } else {
124 tinyData_.clear();
125 tinyData_.shrink_to_fit();
126 const auto sizePages = memory::AllocationTraits::numPages(size_);
127 if (cache->allocator()->allocateNonContiguous(sizePages, data_)) {
128 cache->incrementCachedPages(data().numPages());
129 } else {
130 // No memory to cover 'this'.
131 release();
132 _BOLT_THROW(
133 BoltRuntimeError,
134 error_source::kErrorSourceRuntime.c_str(),
135 error_code::kNoCacheSpace.c_str(),
136 /* isRetriable */ true,
137 "Failed to allocate {} bytes for cache",
138 size_);
139 }
140 }
141}
142
143void AsyncDataCacheEntry::makeEvictable() {
144 accessStats_.lastUse = 0;

Callers 1

initEntryMethod · 0.45

Calls 7

incrementCachedPagesMethod · 0.80
cacheMethod · 0.45
resizeMethod · 0.45
clearMethod · 0.45
allocateNonContiguousMethod · 0.45
allocatorMethod · 0.45
numPagesMethod · 0.45

Tested by

no test coverage detected