MCPcopy Create free account
hub / github.com/Niko1221/Strata / commit_flip

Method commit_flip

engine/src/core/expert_source.cpp:5205–5230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5203}
5204
5205int64_t FileExpertSource::commit_flip() {
5206 int64_t n = 0;
5207 fs_hold_staged(true); // (already held by commit_copies; idempotent)
5208 for (const Exchange& x : staged_) {
5209 const uint8_t* src = override_[x.out];
5210 if (exchange_storage_.active()) { // STRATA_EXCHANGE_ROTATE: the same ownership transfer as commit_exchanges
5211 if (!exchange_storage_.commit(x.in, x.out, (size_t) x.q, src, (size_t) x.bytes)) {
5212 std::fprintf(stderr, "FileExpertSource: invalid exchange rotation commit; refusing corrupt residency\n");
5213 std::abort();
5214 }
5215 ++n;
5216 override_[x.out] = nullptr;
5217 continue;
5218 }
5219 const uint64_t at = complement_offsets_[x.in];
5220 // the same test as commit_copies: an exchange whose bytes were copied is the one that flips
5221 if (src != nullptr && at != kNoComplement && at <= complement_bytes_ && x.bytes <= complement_bytes_ - at &&
5222 complement_host_ != nullptr && detail::exchange_cache_complement(complement_offsets_, x.in, x.out))
5223 ++n;
5224 override_[x.out] = nullptr;
5225 }
5226 fs_hold_staged(false);
5227 staged_.clear();
5228 exchanges_ += n;
5229 return n;
5230}
5231
5232const uint8_t* FileExpertSource::resident_blob(int64_t layer, int64_t expert) const {
5233 if (!complement_ready_ || complement_host_ == nullptr || layer < 0 || expert < 0 || layer >= n_layers_ ||

Callers 1

test_foresight_exchangeFunction · 0.45

Calls 5

abortFunction · 0.50
activeMethod · 0.45
commitMethod · 0.45
clearMethod · 0.45

Tested by 1

test_foresight_exchangeFunction · 0.36