MCPcopy Create free account
hub / github.com/Snapchat/Valdi / initializeBundle

Method initializeBundle

valdi/src/valdi/runtime/Resources/ResourceManager.cpp:160–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 auto flatName =
159 BytesUtils::sha256String(reinterpret_cast<const Byte*>(modulePathView.data()), modulePathView.size());
160 auto mmapPath = mmapCacheDir.appending(std::string_view(flatName));
161 return ValdiModuleArchive::decompress(data.data(), data.size(), mmapPath, &usedMmap, &mmapPublishFailed);
162 }
163 return ValdiModuleArchive::decompress(data.data(), data.size());
164 }();
165 auto decompressDuration = decompressStopWatch.elapsed();
166
167 // A/B telemetry. Emit a single path counter and a latency timer per call.
168 // Failures don't get a path counter — they wouldn't tell us anything useful
169 // about realized mmap rate.
170 if (result && metrics != nullptr) {
171 if (useMmap) {
172 if (usedMmap) {
173 metrics->emitModuleArchiveMmapSuccess(modulePath);
174 // Emitted alongside Mmap_Success when the rename-into-cache step
175 // failed; the in-memory buffer is still valid but no file was
176 // published. Expected to be ~0 in production.
177 if (mmapPublishFailed) {
178 metrics->emitModuleArchiveMmapPublishFail(modulePath);
179 }
180 } else {
181 metrics->emitModuleArchiveMmapFallback(modulePath);
182 }
183 } else {
184 metrics->emitModuleArchiveHeap(modulePath);
185 }
186 metrics->emitModuleDecompressLatency(modulePath, decompressDuration);
187 }
188
189 if (!result) {
190 return result.moveError();
191 }
192 return Valdi::makeShared<ValdiModuleArchive>(result.moveValue());
193}
194
195BundleInitializer ResourceManager::registerBundle(const StringBox& bundleName) {

Callers

nothing calls this directly

Calls 10

getBundleMethod · 0.80
containsEntryMethod · 0.80
registerManifestMethod · 0.80
assets_sizeMethod · 0.80
has_artifactMethod · 0.80
initWithRemoteArchiveMethod · 0.80
initWithLocalArchiveMethod · 0.80
getNameMethod · 0.45
getEntryMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected