server: report how long bringup took, as a raw figure

A restart's cost is the one number a reader needs in order to decide whether one
is worth suffering, and any guess at it would decide the answer by itself. The
server knows it exactly: the interval from process start to the socket listening,
on this machine, with this model and this cache state.

Emitted on /stats as startup_s, 0 until the server has listened. Raw figure only
-- the page no longer consumes it. It is here because it is the missing half of
any restart decision a human or a tool makes downstream, and because the
decode-step advisory that did consume it was withdrawn the same day it shipped
(see the following commit for what the live data showed).

Trailing zero-defaulted field on both SchedMetrics structs plus the adapter copy;
neither struct is ABI-pinned, so this is the sanctioned append.

Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI

(cherry picked from commit 76a9e2f7a28b8e034cfd56caa091792c68fe19b6)
This commit is contained in:
Memoria (Noblistic) committed 2026-10-19 17:35:05 +00:00
1 parent ed2da8c9da
commit d4998b1f75
7 files changed
+53

No files matched your search

+25
View File
@@ -8,6 +8,7 @@
* groups, where summing or picking the wrong group goes wrong silently.
*/
#include "server_fakes.h"
#include "rad_internal.h" /* rad_mono_ns: a synthetic bringup start */
#include <set>
@@ -246,6 +247,30 @@ TEST(sessions_lists_each_conversation_and_what_the_tiers_did) {
/* Every field the page's script reads from /stats (in its update and the request table) and from
* /sessions (its loader and the session rows) is one the routes emit for a populated engine. A
* rename on either side otherwise blanks a panel and reports nothing. */
/* The price of a restart, measured rather than guessed: whatever decides whether a restart is
* worth suffering needs this figure, and a guessed cost would decide the answer by itself. The
* page stopped consuming it on 2026-10-18, when the payback clause it fed was withdrawn -- the
* field stays because it is the missing half of that decision made downstream, by a human or a
* tool. A test runs in microseconds, so a real note_ready() would compute 0 -- indistinguishable
* from "never called". Passing a synthetic start exercises the arithmetic through the real route. */
TEST(stats_reports_how_long_bringup_took_once_the_server_listens) {
Dash d(false);
/* Before the server has listened, there is no measured cost to report. */
CHECK_EQ(d.get("/stats").value("startup_s", (int64_t)-1), (int64_t)0);
d.srv->note_ready(rad_mono_ns() - 47ull * 1000000000ull);
CHECK_EQ(d.get("/stats").value("startup_s", (int64_t)-1), (int64_t)47);
/* A start in the future is not a negative cost: the figure is a duration, and a page that
* divided by it would otherwise be handed a sign flip. */
d.srv->note_ready(rad_mono_ns() + 10ull * 1000000000ull);
CHECK_EQ(d.get("/stats").value("startup_s", (int64_t)-1), (int64_t)47);
/* 0 means "not yet", so it must not overwrite a measured figure. */
d.srv->note_ready(0);
CHECK_EQ(d.get("/stats").value("startup_s", (int64_t)-1), (int64_t)47);
}
TEST(every_field_the_page_reads_is_one_the_routes_emit) {
Dash d(false);
HttpResponse page = d.srv->router().call("GET", "/");