stage request performance snapshots

This commit is contained in:
root
2026-07-16 11:46:14 +00:00
parent 82aec81465
commit 27d0258e1f
2 changed files with 28 additions and 16 deletions
+7 -1
View File
@@ -151,7 +151,13 @@ RENDER(Request& context)
check("to_u64() / to_s64() / to_f64() / to_bool()", to_u64(cfg["u64"], 7) == 42 && to_u64(cfg["bad"], 7) == 7 && to_s64(cfg["s64"], 5) == -12 && to_s64(cfg["bad"], 5) == 5 && to_f64(cfg["f64"], 1.0) > 3.49 && to_f64(cfg["bad"], 1.25) == 1.25 && to_bool(cfg["yes"], false) && !to_bool(cfg["no"], true) && !to_bool("unknown", false), var_dump(cfg)); check("to_u64() / to_s64() / to_f64() / to_bool()", to_u64(cfg["u64"], 7) == 42 && to_u64(cfg["bad"], 7) == 7 && to_s64(cfg["s64"], 5) == -12 && to_s64(cfg["bad"], 5) == 5 && to_f64(cfg["f64"], 1.0) > 3.49 && to_f64(cfg["bad"], 1.25) == 1.25 && to_bool(cfg["yes"], false) && !to_bool(cfg["no"], true) && !to_bool("unknown", false), var_dump(cfg));
DValue perf = request_perf(); DValue perf = request_perf();
check("request_perf()", perf.get_type_name() != "invalid", json_encode(perf)); bool perf_stable = perf["worker_pid"].to_u64() > 0 && perf["running_us"].to_f64() > 0;
for(u64 i = 0; i < 512 && perf_stable; i++)
{
perf = request_perf();
perf_stable = perf["worker_pid"].to_u64() > 0 && perf["running_us"].to_f64() > 0;
}
check("request_perf() stages stable repeated snapshots", perf_stable, json_encode(perf));
u64 parsed_epoch = time_parse("1970-01-01 00:00:05 UTC"); u64 parsed_epoch = time_parse("1970-01-01 00:00:05 UTC");
String utc_year = time_format_utc("%Y", parsed_epoch); String utc_year = time_format_utc("%Y", parsed_epoch);
+7 -1
View File
@@ -1711,6 +1711,9 @@ private:
})); }));
if(mod == "env" && name == "uce_host_request_perf") if(mod == "env" && name == "uce_host_request_perf")
return(add([self](Caller, Span<const Val> args, Span<Val> results) -> Result<std::monostate, Trap> { return(add([self](Caller, Span<const Val> args, Span<Val> results) -> Result<std::monostate, Trap> {
String encoded;
if(!self->hostcall_staged("request_perf", encoded))
{
DValue response; DValue response;
if(self->request_perf.active) if(self->request_perf.active)
{ {
@@ -1727,7 +1730,10 @@ private:
if(self->workspace_birth_us > 0) if(self->workspace_birth_us > 0)
response["workspace_birth_us"] = (f64)self->workspace_birth_us; response["workspace_birth_us"] = (f64)self->workspace_birth_us;
} }
String encoded = ucb_encode(response); encoded = ucb_encode(response);
if(args[2].i32() == 0)
self->hostcall_stage("request_perf", encoded);
}
u32 cap = (u32)args[3].i32(); u32 cap = (u32)args[3].i32();
int32_t buf = args[2].i32(); int32_t buf = args[2].i32();
if(buf != 0 && cap >= encoded.size()) if(buf != 0 && cap >= encoded.size())