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

Method ram_worker

engine/src/core/expert_source.cpp:5113–5143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5111}
5112
5113void FileExpertSource::ram_worker() {
5114 strata::platform::name_this_thread("strata-ram");
5115 for (;;) {
5116 RamJob* job = nullptr;
5117 {
5118 std::unique_lock<std::mutex> lk(ram_mu_);
5119 ram_cv_.wait(lk, [&] {
5120 if (ram_quit_) return true;
5121 for (const auto& j : ram_jobs_)
5122 if (j->state == 0) return true;
5123 return false;
5124 });
5125 if (ram_quit_) return;
5126 for (const auto& j : ram_jobs_)
5127 if (j->state == 0) { job = j.get(); break; }
5128 job->state = 1;
5129 }
5130 const uint64_t bytes = layer_blob_bytes_[(size_t) job->layer];
5131 job->buf.resize((size_t) bytes);
5132 const auto t0 = std::chrono::steady_clock::now();
5133 const bool ok = copy_from_files(job->layer, job->in, job->buf.data());
5134 file_us_.fetch_add((uint64_t) std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - t0).count(),
5135 std::memory_order_relaxed);
5136 if (ok) {
5137 file_read_bytes_.fetch_add(bytes, std::memory_order_relaxed);
5138 ram_staged_reads_.fetch_add(1, std::memory_order_relaxed);
5139 }
5140 std::lock_guard<std::mutex> lk(ram_mu_);
5141 job->state = ok ? 2 : 3;
5142 }
5143}
5144
5145int64_t FileExpertSource::ram_install(const int32_t* host_res, int64_t n_expert) {
5146 std::vector<std::unique_ptr<RamJob>> done;

Callers

nothing calls this directly

Calls 8

fetch_addMethod · 0.80
getMethod · 0.65
name_this_threadFunction · 0.50
nowFunction · 0.50
waitMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected