Files
Deadcode 3b13fd3266 radiance 2.3.0
New models. Thinking Machines' Inkling 2 Mini by gostar (#584-#586): its text backbone and loop, the
release's NVFP4 and MXFP8 checkpoint read by the converter, an int8 trunk, the vision tower, tensor
parallelism, tool calls (with Warzuponus) and an image processor that matches transformers bit for
bit (millaguie). Inkling's routed experts are served in IQR-V4's four-bit trellis (moe_gemm_iqr),
fitted by GPTQ against Hessians the plugin now records (`--calib-dir`), its token embedding in int8
(read in place by embed_lookup), and incoai's DFlash2 drafter in four bits in place of the release's
DSpark. That container, 14.4 GiB with the vision tower, decodes 190 / 427 / 658 tokens a second at 1
/ 4 / 8 streams at tp 2 on two R9700 with `draft-window: adaptive` (code 240 / 550 / 790,
step-by-step arithmetic 358 / 811 / 1116): 19-43% ahead of the same target with the release's DSpark
drafter and 45-83% ahead of the all-int8 container (26.1 GiB, 124 / 263 / 386), at a mean KL of
0.0066 against the release's weights (int8: 0.0042). DeepSeek-V4.1-Flash on 2.x by baKon (#583),
with its vision tower, its IQ1_S and IQ2_XXS containers and linears and experts served in
llama.cpp's own blocks; parts ported from mikoskinen/r9700-exact-serving by Dad_Vibes' fork.
GLM-5.3-Flash on 2.x with its IQR / IQ8R container, an int8 latent cache and four-card serving by
AnimusNull (#566). Gemma 4 dense on EXL3-V3 by keptn42 (#537), on the EXL3 dense rows and
qwen35_exl3 tensor parallelism by Hero422. NVIDIA's 2-bit Nemotron-3.5-Bolt-74B-A9B on one card by
keptn42 (#477). Wan 2.2 TI2V-5B text-to-video and first-frame video by rkcth (#535). LFM3-1.7B on
RDNA3 iGPUs by DokterSmol (#578). Qwen3.8-27B in bf16 with the DFlash2 drafter, and bf16x12, bf16
weights packed losslessly in 12.25 bits, by eddie168 (#577). Int8 experts for drama-3 by morevgalex
(#598).

Speculative decoding. Draft trees for Qwen3.8-27B's DFlash2 drafts by Kezi (#450, opt-in): one card,
+17% at one stream and +14% at two. --draft-max-lanes and --draft-min-accept, two gates on a block
drafter, and --draft-window-ckpt, its window KV kept in the checkpoint slots, by rkcth (#600-#602).
`draft-window: adaptive` verifies each sequence's drafts up to the first one unlikely to be kept. A
verify's rows share each K and V tile in Inkling's attention by gostar (#608): 93 to 118 tokens a
second at a 70k-token prompt on one card.

Generation. Krea 2 instruction edits with one or two references and registered outfill, LoRA on the
image generators with bias deltas and row-mixer adapters applied per request, and MiniMax-H3's
model-declared sparse attention profiles, by rkcth (#534, #542, #543, #605-#609). MiniMax-H3's audio
reference guide pinned from a frame by 1beb (#595). LTX-2's chunk ceiling raised to 40 by Itoash
(#570).

Fleets and memory. memory.queue-reserve, the hardware queues a card keeps ready, by kevinjd (#589).
memory.pinned-numa-node by Foundry (#580). memory.card-headroom-mib on single-model tensor-parallel
budgets by zihaomu (#624). Parked weights rebuilt on the CPU, memory ownership kept across a failed
handoff and quiescent callbacks serialised, by rkcth (#557-#561). A warm load may unload a parked
model (#592); the first card listed chooses the architecture (#458).

Kernels. libr3d's packed dense IQR GEMM and routed IQR expert rows on gfx1100, and libhalo's GEMV
decode for Qwen3.8-Flash-Next's MoE down, by zihaomu (#562, #620, #622). GGML IQ2_XXS and IQ3_XXS
packed on the card by baKon.

Dashboard. KV cache in tokens (in use, capacity now and with all flexible space), live figures
through long prefill steps, step / decode / prefill / acceptance lines without holes, and expert hit
rates only on tiered models. Seven tile and history defects fixed by Noblistic (#597), vision
encoder and per-card hardware figures by davetha (#574), per-LoRA attribution by dowjames (#552).

Fixed. return_tokens / return_token_ids on the OpenAI endpoints (#571). reasoning_effort "none" and
"minimal" reach a template that takes them as levels, by millaguie (#608). Misaligned loads in the
windowed paged attention over an int8 cache (#540). A retired 27B head refused by name (#541).
rad-convert's GPU trellis jobs kept fed, and --reuse-only, by gostar (#575). jinja's tojson takes
sort_keys by Warzuponus (#582). hfget measures file sizes with stat, by kepler_62f (#623). The
tested C++ compiler is stated in the build guide by lowell80 (#551). The codebase was cleaned up:
shared helpers instead of repeated blocks, and the int8 linear, activation and GEMM code no longer
named after the retired fp8 formats.

Inkling 2 Mini is served in one form: IQR-V4 experts with the DFlash2 drafter
(StillDeadcode/inkling-2-mini-iq4r-v4 on Hugging Face, or
data/recipes/inkling2-mini-iq4r-v4.recipe). A container with the release's DSpark drafter, or with
NVFP4, int8 or 4-bit experts, is refused by name and needs converting again.

Plugin ABI 44: out-of-tree plugins need to be rebuilt.

Thanks to @gostar, @baKon, @Dad_Vibes, @AnimusNull, @keptn42, @Hero422, @rkcth, @DokterSmol,
@eddie168, @morevgalex, @Kezi, @1beb, @Itoash, @kevinjd, @Foundry, @zihaomu, @Noblistic, @davetha,
@dowjames, @Warzuponus, @millaguie, @kepler_62f, @lowell80 and @Code000.
2026-11-26 15:28:37 +01:00

481 lines
21 KiB
C++

/* core/server/history.cpp -- see history.h. */
#include "server/history.h"
#include <chrono>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <initializer_list>
#include <limits>
namespace rad {
namespace server {
namespace {
const double kNone = std::numeric_limits<double>::quiet_NaN();
/* A member's number, or NaN where the object has none. */
double num(const json& o, const char* k) {
if (!o.is_object() || !o.contains(k)) return kNone;
const json& v = o[k];
return v.is_number() ? v.get<double>() : kNone;
}
double num0(const json& o, const char* k) {
const double v = num(o, k);
return std::isfinite(v) ? v : 0.0;
}
const json* member(const json& o, const char* k) {
return o.is_object() && o.contains(k) ? &o[k] : nullptr;
}
std::string text(const json& o, const char* k) {
if (!o.is_object() || !o.contains(k)) return std::string();
const json& v = o[k];
return v.is_string() ? v.get<std::string>() : v.dump();
}
/* Four significant digits: what a chart resolves, and a third of the bytes on the wire. */
double round4(double v) {
char b[32];
std::snprintf(b, sizeof b, "%.4g", v);
return std::strtod(b, nullptr);
}
void put(History::Row& r, const char* k, double v) {
if (std::isfinite(v)) r.emplace_back(k, v);
}
/* A model's state as a level a chart can draw; an unknown state is 0. */
double state_code(const std::string& s) {
if (s == "resident") return 3;
if (s == "loading" || s == "closing") return 2;
if (s == "parked") return 1;
if (s == "failed") return 4;
if (s == "waiting") return 5;
return 0;
}
} // namespace
/* ------------------------------------------------------------------ rows */
History::Row History::model_row(const json& s, const json* prev, double dt) {
Row row;
/* What the model is doing at this sample, from its live requests and the step under way. The
* counters are published when a step ends, so inside a long step they still describe the one
* before; the request states and the open step do not lag. */
bool in_prefill = false, in_decode = false;
if (const json* rq = member(s, "requests"); rq && rq->is_array())
for (const json& r : *rq) {
const std::string st = text(r, "state");
in_prefill |= st == "prefill";
in_decode |= st == "decode";
}
const double open_phase = num(s, "step_open_phase");
in_prefill |= open_phase == 0.0 || open_phase == 2.0;
auto advanced = [&](std::initializer_list<const char*> fields) {
if (!prev) return true;
double now = 0, was = 0;
for (const char* f : fields) {
now += num0(s, f);
was += num0(*prev, f);
}
return now > was;
};
const bool busy = in_prefill || in_decode || num0(s, "running") > 0 || open_phase >= 0.0
|| (prev && advanced({ "steps" }));
put(row, "busy", busy ? 1.0 : 0.0);
/* The decode and prefill rates are the engine's own recent averages, which hold their last
* value while nothing of their kind runs (the decay is keyed to steps of any kind), so with no
* work of that kind they read 0. Where such work exists but none of its steps finished since
* the last sample (a long prefill step holds decode back) the rate is left out, and the page
* draws through those gaps while the model is busy. */
if (const double d = num(s, "decode_tps"); std::isfinite(d)) {
if (advanced({ "steps_decode" })) put(row, "decode", d);
else if (!in_decode) put(row, "decode", 0.0);
}
if (const double p = num(s, "prefill_tps"); std::isfinite(p)) {
if (in_prefill || advanced({ "steps_prefill", "steps_mixed" })) {
if (p > 0.0 || !in_prefill) put(row, "prefill", p);
} else {
put(row, "prefill", 0.0);
}
}
put(row, "running", num(s, "running"));
put(row, "waiting", num(s, "waiting"));
put(row, "preempted", num(s, "preempted"));
put(row, "flight", num(s, "in_flight"));
put(row, "hit", num(s, "prefix_hit_rate"));
put(row, "kvUsed", num(s, "kv_bytes_used"));
put(row, "kvCap", num(s, "kv_bytes_total"));
/* The same pool in tokens: held now, what the pool holds at present, and what it could hold
* with every block of its carve (VRAM lent to the expert slab included). */
put(row, "kvTokUsed", num(s, "kv_tokens_used"));
put(row, "kvTokCap", num(s, "kv_tokens_total"));
if (const double mx = num(s, "kv_tokens_max"); mx > num0(s, "kv_tokens_total"))
put(row, "kvTokMax", mx);
/* The pool's bytes split by tokens: what finished turns keep for reuse and what running
* requests read. */
{
const double held = num0(s, "kv_bytes_used"), used = num0(s, "kv_tokens_used");
const double kept = std::min(num0(s, "kv_tokens_cached"), used);
const double kept_b = used > 0 ? held * kept / used : 0.0;
put(row, "kvKept", kept_b);
put(row, "kvRead", std::max(0.0, held - kept_b));
put(row, "kvTokKept", kept);
put(row, "kvTokRead", std::max(0.0, used - kept));
}
if (const double best = num(s, "step_ns_decode_best"); best > 0) put(row, "stepBest", best / 1e6);
const json* jobs = member(s, "jobs");
if (jobs) {
put(row, "jobRun", num(*jobs, "running"));
put(row, "jobDone", num(*jobs, "done"));
}
/* A prompt's fresh tokens over its own prefill time, for the requests whose prefill ended
* since the last sample: the scheduler's rate divides by everything the step loop did, so
* one short prompt among long decodes would read as a few tokens a second. */
if (const json* rq = member(s, "requests"); rq && rq->is_array()) {
std::set<std::string> seen;
if (prev)
if (const json* pq = member(*prev, "requests"); pq && pq->is_array())
for (const json& r : *pq)
if (num(r, "prefill_s") > 0) seen.insert(text(r, "id"));
double sum = 0;
int n = 0;
for (const json& r : *rq) {
const double pf = num(r, "prefill_s"), fresh = num0(r, "prompt") - num0(r, "cached");
if (pf > 0 && fresh > 0 && !seen.count(text(r, "id"))) {
sum += fresh / pf;
++n;
}
}
if (n) put(row, "prefillRate", sum / n);
}
put(row, "encWait", num(s, "encode_pending"));
if (!prev || !(dt > 0)) return row;
const json& p = *prev;
/* The encoder's share of the time between samples, and its items and patches a second. A
* counter that went back (a reload under the same start) is a gap, not a negative rate.
* encode_ns grows while a pass runs (Scheduler::take_encodes), so a long pass reads busy on
* every sample it spans; the clamp only absorbs the jitter between the sampler's clock and
* the server's. Items and patches count when their pass ends. */
{
auto d = [&](const char* f) {
const double v = num(s, f) - num(p, f);
return v >= 0 ? v : kNone;
};
put(row, "encBusy", std::clamp(d("encode_ns") / (dt * 1e9), 0.0, 1.0));
put(row, "encRate", d("encode_items") / dt);
put(row, "encPatch", d("encode_patches") / dt);
}
if (jobs)
if (const json* pj = member(p, "jobs"); pj && num0(*jobs, "done") > num0(*pj, "done"))
put(row, "jobTime", num(*jobs, "last_ms") / 1000.0);
put(row, "reqRate", std::max(0.0, (num0(s, "total_requests") - num0(p, "total_requests")) / dt));
if (const double steps = num0(s, "steps") - num0(p, "steps"); steps > 0)
put(row, "stepAny", (num0(s, "step_ns") - num0(p, "step_ns")) / steps / 1e6);
const double ds = num0(s, "steps_decode") - num0(p, "steps_decode");
if (ds > 0) put(row, "step", (num0(s, "step_ns_decode") - num0(p, "step_ns_decode")) / ds / 1e6);
/* Acceptance is accepted over reached, summed over the draft positions that were verified. */
{
const json* dp = member(s, "draft_positions");
const json* pp = member(p, "draft_positions");
if (dp && pp && dp->is_array() && pp->is_array() && dp->size() == pp->size()) {
double reached = 0, accepted = 0;
for (size_t i = 0; i < dp->size(); ++i) {
const double dr = num0((*dp)[i], "reached") - num0((*pp)[i], "reached");
const double da = num0((*dp)[i], "accepted") - num0((*pp)[i], "accepted");
if (dr > 0) {
reached += dr;
accepted += da;
}
}
if (reached > 0) put(row, "accept", accepted / reached);
if (reached > 0 && ds > 0) put(row, "tokStep", 1.0 + accepted / ds);
}
}
{
const json* lk = member(s, "link");
const json* lp = member(p, "link");
if (lk && lp) {
auto d = [&](const char* f) { return std::max(0.0, (num0(*lk, f) - num0(*lp, f)) / dt); };
put(row, "lkAr", d("ar_bytes"));
put(row, "lkUp", d("h2d_bytes"));
put(row, "lkDn", d("d2h_bytes"));
put(row, "lkSsd", d("ssd_bytes"));
put(row, "lkStream", d("stream_bytes") + d("kv_stream_bytes"));
}
}
{
const json* ex = member(s, "experts");
const json* xp = member(p, "experts");
/* Nothing to hit or move while every expert sits in VRAM. */
const json* tf = ex ? member(*ex, "tiered") : nullptr;
if (ex && xp && tf && tf->is_boolean() && tf->get<bool>()) {
if (const double routed = num0(*ex, "routed") - num0(*xp, "routed"); routed > 0)
put(row, "expHit", (num0(*ex, "routed_res") - num0(*xp, "routed_res")) / routed);
put(row, "expIn", std::max(0.0, (num0(*ex, "promotions") - num0(*xp, "promotions")) / dt));
put(row, "expOut", std::max(0.0, (num0(*ex, "demotions") - num0(*xp, "demotions")) / dt));
}
}
return row;
}
History::Row History::fleet_row(const json& f) {
Row row;
const json* models = member(f, "models");
const json* cards = member(f, "cards");
if (models && models->is_array())
for (const json& m : *models) row.emplace_back("s:" + text(m, "id"), state_code(text(m, "state")));
if (!cards || !cards->is_array()) return row;
for (const json& c : *cards) {
const std::string card = text(c, "card");
auto name = [&](const char* k) { return std::string(k) + card; };
if (const double v = num(c, "busy"); std::isfinite(v)) row.emplace_back(name("busy"), v);
if (const double v = num(c, "power_w"); std::isfinite(v)) row.emplace_back(name("power"), v);
if (const double v = num(c, "temp_c"); std::isfinite(v)) row.emplace_back(name("temp"), v);
if (const double v = num(c, "mem_busy"); std::isfinite(v)) row.emplace_back(name("memb"), v);
if (const double v = num(c, "sclk_mhz"); std::isfinite(v)) row.emplace_back(name("sclk"), v);
if (const double v = num(c, "mclk_mhz"); std::isfinite(v)) row.emplace_back(name("mclk"), v);
if (const double v = num(c, "temp_mem_c"); std::isfinite(v)) row.emplace_back(name("tmem"), v);
if (const double v = num(c, "fan_pct"); std::isfinite(v)) row.emplace_back(name("fan"), v);
if (const double v = num(c, "free_bytes"); std::isfinite(v)) row.emplace_back(name("free"), v);
if (!models || !models->is_array()) continue;
/* A model's bytes on this card, 0 where it holds none: the stacked memory chart draws a
* model that left as an empty band, not as a gap. */
const double ci = num(c, "card");
for (const json& m : *models) {
double bytes = 0;
/* What the model holds on this card now (a loading or partly parked one too), else
* its claim on each of its cards. */
const json* by = member(m, "vram_bytes_by_card");
if (by && by->is_object()) {
if (const auto it = by->find(card); it != by->end() && it->is_number()) bytes = it->get<double>();
} else if (const json* on = member(m, "cards"); on && on->is_array()) {
for (const json& x : *on)
if (x.is_number() && x.get<double>() == ci) bytes = num0(m, "vram_bytes_per_card");
}
row.emplace_back("c" + card + ":" + text(m, "id"), bytes);
}
}
return row;
}
/* ------------------------------------------------------------------ the ring */
void History::Series::push(double at, const Row& row) {
if (t.empty()) t.assign((size_t)kRows, 0.0);
const size_t i = head;
/* Kept as it is written out, to the millisecond: a page asks for what came after the last
* time it was given, and a time kept finer than it was sent would be later than itself. */
t[i] = std::round(at * 1000.0) / 1000.0;
for (auto& [k, col] : c) col[i] = std::numeric_limits<float>::quiet_NaN();
for (const auto& [k, v] : row) {
auto it = c.find(k);
if (it == c.end())
it = c.emplace(k, std::vector<float>((size_t)kRows, std::numeric_limits<float>::quiet_NaN())).first;
it->second[i] = (float)v;
}
head = (head + 1) % (size_t)kRows;
if (n < (size_t)kRows) ++n;
}
void History::Series::write(json& out, double since) const {
json times = json::array();
json cols = json::object();
std::vector<size_t> at;
const size_t first = (head + (size_t)kRows - n) % (size_t)kRows;
/* The ring holds the hour at its fastest rate, so at one row a second it holds more than the
* hour: only what is within kKeepS of the latest row is given. */
const double oldest = n ? t[(head + (size_t)kRows - 1) % (size_t)kRows] - (double)kKeepS : 0.0;
for (size_t k = 0; k < n; ++k) {
const size_t i = (first + k) % (size_t)kRows;
if (t[i] > since && t[i] > oldest) at.push_back(i);
}
for (size_t i : at) times.push_back(t[i]);
for (const auto& [name, col] : c) {
bool any = false;
for (size_t i : at) any = any || std::isfinite(col[i]);
if (!any) continue;
json a = json::array();
for (size_t i : at) {
if (std::isfinite(col[i])) a.push_back(round4((double)col[i]));
else a.push_back(nullptr);
}
cols[name] = std::move(a);
}
out["keep_s"] = kKeepS;
out["t"] = std::move(times);
out["c"] = std::move(cols);
}
/* ------------------------------------------------------------------ samples */
void History::track_requests(Model& m, const json& stats, double t) {
auto finish = [&](const json& r) {
const double fresh = num0(r, "prompt") - num0(r, "cached");
const double pf = num(r, "prefill_s"), ttft = num(r, "ttft_s"), tps = num(r, "tps");
json h;
h["id"] = text(r, "id");
if (!text(r, "lora").empty()) h["lora"] = text(r, "lora");
h["prompt"] = num0(r, "prompt");
h["out"] = num0(r, "output");
h["ctx"] = num0(r, "ctx");
if (std::isfinite(ttft)) h["ttft"] = ttft; else h["ttft"] = nullptr;
if (pf > 0 && fresh > 0) h["pf"] = round4(fresh / pf); else h["pf"] = nullptr;
if (tps > 0) h["tps"] = round4(tps); else h["tps"] = nullptr;
h["at"] = (int64_t)std::llround(t * 1000.0);
m.finished.push_back(std::move(h));
if (m.finished.size() > (size_t)kRequests) m.finished.pop_front();
};
std::set<std::string> seen;
if (const json* rq = member(stats, "requests"); rq && rq->is_array())
for (const json& r : *rq) {
const std::string id = text(r, "id");
if (id.empty()) continue;
seen.insert(id);
m.live[id] = r;
if (text(r, "state") == "done" && m.done.insert(id).second) finish(r);
}
/* A request that left the table without being seen done ended between two samples. */
for (auto it = m.live.begin(); it != m.live.end();) {
if (seen.count(it->first)) {
++it;
continue;
}
if (!m.done.count(it->first)) finish(it->second);
m.done.erase(it->first);
it = m.live.erase(it);
}
}
void History::model_sample(const std::string& id, const json& stats, double t, std::string body) {
std::lock_guard<std::mutex> lk(mu_);
Model& m = models_[id];
m.latest = std::move(body);
/* Counters start over with the model: a sample of another start is no predecessor. */
const bool same = m.prev.is_object() && num(m.prev, "started_at") == num(stats, "started_at");
if (!same) {
m.live.clear();
m.done.clear();
}
Row row = model_row(stats, same ? &m.prev : nullptr, t - m.prev_t);
/* The model's cards' figures under the fleet's own column names (busy<c>, memb<c>, ...), from the
* latest fleet sample: a page that may read this model but not the fleet still sees what its
* cards are doing while no step runs (an encode, a load). */
if (const auto it = model_cards_.find(id); it != model_cards_.end() && cards_.is_array())
for (const json& c : cards_) {
const std::string card = text(c, "card");
if (std::find(it->second.begin(), it->second.end(), card) == it->second.end()) continue;
static const std::pair<const char*, const char*> kCols[] = {
{ "busy", "busy" }, { "power_w", "power" }, { "temp_c", "temp" }, { "mem_busy", "memb" },
{ "sclk_mhz", "sclk" }, { "mclk_mhz", "mclk" }, { "temp_mem_c", "tmem" }, { "fan_pct", "fan" } };
for (const auto& [k, col] : kCols)
if (const double v = num(c, k); std::isfinite(v)) row.emplace_back(col + card, v);
}
m.series.push(t, row);
track_requests(m, stats, t);
m.prev = stats;
m.prev_t = t;
}
void History::fleet_sample(const json& fleet, double t, std::string body) {
std::lock_guard<std::mutex> lk(mu_);
fleet_.push(t, fleet_row(fleet));
cards_ = json();
if (const json* c = member(fleet, "cards"); c && c->is_array()) cards_ = *c;
model_cards_.clear();
if (const json* ms = member(fleet, "models"); ms && ms->is_array())
for (const json& m : *ms)
if (const json* on = member(m, "cards"); on && on->is_array())
for (const json& x : *on)
if (x.is_number()) model_cards_[text(m, "id")].push_back(std::to_string(x.get<long long>()));
fleet_live_ = std::move(body);
}
namespace {
int64_t steady_ns() {
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now().time_since_epoch()).count();
}
} // namespace
bool History::watched(double seconds) const {
const int64_t at = asked_ns_.load(std::memory_order_relaxed);
return at != 0 && (double)(steady_ns() - at) * 1e-9 < seconds;
}
void History::model_closed(const std::string& id) {
std::lock_guard<std::mutex> lk(mu_);
if (auto it = models_.find(id); it != models_.end()) it->second.latest.clear();
}
void History::forget(const std::string& id) {
std::lock_guard<std::mutex> lk(mu_);
models_.erase(id);
}
json History::model_since(const std::string& id, double since) const {
std::lock_guard<std::mutex> lk(mu_);
json out = json::object();
json reqs = json::array();
auto it = models_.find(id);
if (it == models_.end()) {
Series().write(out, since);
} else {
it->second.series.write(out, since);
for (const json& h : it->second.finished)
/* In whole milliseconds on both sides, as `at` is. */
if (num0(h, "at") > (double)std::llround(since * 1000.0)) reqs.push_back(h);
}
out["requests"] = std::move(reqs);
return out;
}
json History::fleet_since(double since) const {
std::lock_guard<std::mutex> lk(mu_);
json out = json::object();
fleet_.write(out, since);
return out;
}
namespace {
/* `{...}` with `"live": <text>` appended, the text spliced in as it was read. */
std::string with_live(const json& o, const std::string& live) {
std::string b = o.dump();
b.pop_back();
b += ",\"live\":";
b += live.empty() ? "null" : live;
b += '}';
return b;
}
} // namespace
std::string History::model_body(const std::string& id, double since) const {
asked_ns_.store(steady_ns(), std::memory_order_relaxed);
const json o = model_since(id, since);
std::string live;
{
std::lock_guard<std::mutex> lk(mu_);
if (auto it = models_.find(id); it != models_.end()) live = it->second.latest;
}
return with_live(o, live);
}
std::string History::fleet_body(double since) const {
asked_ns_.store(steady_ns(), std::memory_order_relaxed);
const json o = fleet_since(since);
std::string live;
{
std::lock_guard<std::mutex> lk(mu_);
live = fleet_live_;
}
return with_live(o, live);
}
} // namespace server
} // namespace rad