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

Method commit_exchanges

engine/src/core/expert_source.cpp:4975–5004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4973}
4974
4975int64_t FileExpertSource::commit_exchanges() {
4976 int64_t n = 0;
4977 fs_hold_staged(true); // #2134: both experts' bytes move (in's place takes out's bytes, out leaves its buffer)
4978 for (const Exchange& x : staged_)
4979 if (!soft_in_.empty()) soft_in_[x.out] = SIZE_MAX;
4980 for (const Exchange& x : staged_) {
4981 const uint8_t* src = override_[x.out];
4982 if (exchange_storage_.active()) {
4983 if (!exchange_storage_.commit(x.in, x.out, (size_t)x.q, src, (size_t)x.bytes)) {
4984 // Admitting the GPU swap after a failed RAM ownership update would lose an expert.
4985 std::fprintf(stderr, "FileExpertSource: invalid exchange rotation commit; refusing corrupt residency\n");
4986 std::abort();
4987 }
4988 ++n;
4989 override_[x.out] = nullptr;
4990 continue;
4991 }
4992 const uint64_t at = complement_offsets_[x.in];
4993 if (src != nullptr && at != kNoComplement && at <= complement_bytes_ && x.bytes <= complement_bytes_ - at &&
4994 complement_host_ != nullptr) {
4995 std::memcpy((uint8_t*) complement_host_ + (size_t) at, src, (size_t) x.bytes);
4996 if (detail::exchange_cache_complement(complement_offsets_, x.in, x.out)) ++n;
4997 }
4998 override_[x.out] = nullptr;
4999 }
5000 fs_hold_staged(false);
5001 staged_.clear();
5002 exchanges_ += n;
5003 return n;
5004}
5005
5006bool FileExpertSource::replace_resident(int64_t layer, int64_t in, int64_t out) {
5007 if (!complement_ready_ || complement_host_ == nullptr || exchange_storage_.active() || !staged_.empty() ||

Callers 3

test_rotating_sourceFunction · 0.45
test_foresight_exchangeFunction · 0.45
test_replace_residentFunction · 0.45

Calls 7

memcpyFunction · 0.85
abortFunction · 0.50
emptyMethod · 0.45
activeMethod · 0.45
commitMethod · 0.45
clearMethod · 0.45

Tested by 3

test_rotating_sourceFunction · 0.36
test_foresight_exchangeFunction · 0.36
test_replace_residentFunction · 0.36