大重构改完

This commit is contained in:
2026-08-12 21:31:02 +08:00
parent 7c00b8565d
commit 15c3d21f2d
73 changed files with 4303 additions and 1727 deletions
+106 -48
View File
@@ -243,7 +243,7 @@ TEST(RenderiveWebGallery, AdminiveCatalogCoversEveryControlCaseAndThreeModes) {
TEST(RenderiveWebGallery, CatalogOwnsDashboardFieldsAndDynamicBehavior) {
const nlohmann::json catalog = parse_json(Gallery_Protocol::catalog_json());
const auto& dashboard = catalog.at("dashboard");
EXPECT_EQ(dashboard.at("performance").at("fields").size(), 33U);
EXPECT_EQ(dashboard.at("performance").at("fields").size(), 26U);
EXPECT_EQ(dashboard.at("limits").at("fields").size(), 4U);
EXPECT_EQ(dashboard.at("observer").at("sections").size(), 4U);
std::set<std::string> client_sources;
@@ -307,13 +307,11 @@ TEST(RenderiveWebGallery, ObserverTelemetryAndDashboardUseAdminiveDescriptors) {
for (const auto& field : feedback_descriptor.at("fields"))
EXPECT_TRUE(feedback.contains(field.at("name").get<std::string>()));
EXPECT_EQ(observer.at("mode"), "manual");
EXPECT_GT(observer.at("task_worker_count").get<std::size_t>(), 0U);
EXPECT_TRUE(observer.contains("task_execution_state"));
EXPECT_TRUE(observer.contains("task_graph_node_count"));
EXPECT_TRUE(observer.contains("task_running_node_count"));
EXPECT_TRUE(observer.contains("task_pending_node_count"));
EXPECT_TRUE(observer.contains("task_peak_parallelism"));
EXPECT_TRUE(observer.contains("task_graph_duration_ns"));
EXPECT_FALSE(observer.contains("task_worker_count"));
ASSERT_TRUE(telemetry.contains("performance_capture"));
EXPECT_TRUE(telemetry.at("performance_capture").contains("controller"));
EXPECT_TRUE(telemetry.at("performance_capture").contains("sessions"));
EXPECT_TRUE(telemetry.at("performance_capture").contains("plans"));
EXPECT_FALSE(telemetry.contains("low_latency_limit"));
}
@@ -407,16 +405,16 @@ TEST(RenderiveWebGallery, AdminiveResourcesPatchTheRealRenderableState) {
EXPECT_EQ(foreign.at("type"), "error");
}
TEST(RenderiveWebGallery, ExposesEachRenderableObserverAndStableTaskTopology) {
TEST(RenderiveWebGallery, ExposesStateObserversAndOneCompleteRenderDag) {
Gallery_Plot_Session session;
const auto opened = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Open, open_message("spectrum", "manual"))));
ASSERT_EQ(opened.at("type"), "case_state");
const auto& observers = opened.at("controls").at("observers");
const auto& graph = opened.at("controls").at("task_graph");
ASSERT_EQ(observers.size(), graph.at("nodes").size());
const auto& graph = opened.at("controls").at("render_plan");
EXPECT_GE(observers.size(), 7U);
EXPECT_GT(graph.at("nodes").size(), observers.size());
for (const std::string_view target : {"frequency_axis", "value_axis", "spectrum"}) {
const auto found = std::find_if(observers.begin(), observers.end(),
[target](const auto& resource) {
@@ -427,39 +425,41 @@ TEST(RenderiveWebGallery, ExposesEachRenderableObserverAndStableTaskTopology) {
EXPECT_EQ(found->at("descriptor").at("fields").at(0)
.at("presentation").at("label"),
"最近状态事件");
EXPECT_EQ(found->at("data").at("event"), "Render_Completed");
EXPECT_EQ(found->at("data").at("event"), "Published");
EXPECT_GT(found->at("data").at("publish_count").get<std::uint64_t>(), 0U);
EXPECT_GT(found->at("data").at("successful_render_count")
.get<std::uint64_t>(), 0U);
EXPECT_GT(found->at("data").at("task_execution_count")
.get<std::uint64_t>(), 0U);
EXPECT_FALSE(found->at("data").contains("task_execution_count"));
}
ASSERT_TRUE(graph.at("topology_id").is_string());
EXPECT_FALSE(graph.at("topology_id").get<std::string>().empty());
EXPECT_FALSE(graph.at("nodes").empty());
EXPECT_FALSE(graph.at("edges").empty());
ASSERT_EQ(graph.at("renderables").size(), 3U);
const auto spectrum_graph = std::find_if(
graph.at("renderables").begin(), graph.at("renderables").end(),
[](const auto& resource) { return resource.at("target") == "spectrum"; });
ASSERT_NE(spectrum_graph, graph.at("renderables").end());
EXPECT_FALSE(spectrum_graph->at("graph").at("nodes").empty());
ASSERT_EQ(graph.at("renderables").size(), observers.size());
std::set<std::string> kinds;
for (const auto& node : graph.at("nodes"))
kinds.insert(node.at("kind").get<std::string>());
EXPECT_TRUE(kinds.contains("prepare"));
EXPECT_TRUE(kinds.contains("paint"));
EXPECT_TRUE(kinds.contains("composite"));
for (const auto& renderable : graph.at("renderables")) {
EXPECT_TRUE(renderable.contains("prepare_cache"));
EXPECT_TRUE(renderable.contains("paint_cache"));
}
const auto observed = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Observe,
R"({"category":"event","type":"gallery_observe"})")));
ASSERT_EQ(observed.at("type"), "observer_state");
EXPECT_EQ(observed.at("telemetry").at("renderable_observers").size(),
graph.at("nodes").size());
EXPECT_FALSE(observed.at("telemetry").contains("task_graph"));
observers.size());
EXPECT_FALSE(observed.at("telemetry").contains("render_plan"));
const auto refreshed = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Refresh,
R"({"category":"event","type":"gallery_refresh"})")));
ASSERT_EQ(refreshed.at("type"), "refresh_state");
EXPECT_EQ(refreshed.at("controls").at("observers").size(),
graph.at("nodes").size());
observers.size());
EXPECT_EQ(refreshed.at("notice"), "观察数据已手动刷新");
const auto reset = response_json(session.handle(gallery_request(
@@ -469,15 +469,11 @@ TEST(RenderiveWebGallery, ExposesEachRenderableObserverAndStableTaskTopology) {
EXPECT_EQ(reset.at("notice"), "监测滑动窗口已重置");
EXPECT_EQ(reset.at("telemetry").at("performance").at("render_sample_count"), 0);
EXPECT_EQ(reset.at("telemetry").at("performance").at("pixel_encode_sample_count"), 0);
for (const auto& observer : reset.at("telemetry").at("renderable_observers")) {
EXPECT_EQ(observer.at("data").at("successful_render_count"), 0);
EXPECT_EQ(observer.at("data").at("task_execution_count"), 0);
EXPECT_EQ(observer.at("data").at("render_duration_sample_count"), 0);
EXPECT_EQ(observer.at("data").at("task_duration_sample_count"), 0);
}
for (const auto& observer : reset.at("telemetry").at("renderable_observers"))
EXPECT_FALSE(observer.at("data").contains("task_execution_count"));
}
TEST(RenderiveWebGallery, PartitionControlRebuildsTheObservedTaskGraph) {
TEST(RenderiveWebGallery, PartitionControlRebuildsTheUnifiedRenderDag) {
Gallery_Plot_Session session;
ASSERT_EQ(response_json(session.handle(gallery_request(
Gallery_Request_Kind::Open,
@@ -487,33 +483,95 @@ TEST(RenderiveWebGallery, PartitionControlRebuildsTheObservedTaskGraph) {
const auto render = [&session] {
EXPECT_EQ(invoke_action(session, "mode_prepare").at("type"), "case_state");
EXPECT_EQ(invoke_action(session, "mode_refresh").at("type"), "case_state");
return invoke_action(session, "mode_render").at("telemetry").at("kernel_observer");
return invoke_action(session, "mode_render");
};
const auto single_state = patch_controls(
session, {{"partition_mode", "Fixed"}, {"partition_count", 1}}, "spectrum");
ASSERT_EQ(single_state.at("type"), "case_state");
const std::string single_topology = single_state.at("controls").at("task_graph")
.at("topology_id");
const auto single = render();
EXPECT_EQ(single.at("task_execution_state"), "Completed");
EXPECT_EQ(single.at("task_completed_node_count"),
single.at("task_graph_node_count"));
EXPECT_EQ(single.at("task_running_node_count"), 0);
EXPECT_EQ(single.at("task_pending_node_count"), 0);
const auto& single_graph = single.at("controls").at("render_plan");
const std::string single_topology = single_graph.at("topology_id");
const auto partitioned_state = patch_controls(
session, {{"partition_count", 4}}, "spectrum");
ASSERT_EQ(partitioned_state.at("type"), "case_state");
EXPECT_NE(partitioned_state.at("controls").at("task_graph").at("topology_id"),
single_topology);
const auto partitioned = render();
EXPECT_EQ(partitioned.at("task_graph_node_count").get<std::size_t>(),
single.at("task_graph_node_count").get<std::size_t>() + 3U);
EXPECT_EQ(partitioned.at("task_completed_node_count"),
partitioned.at("task_graph_node_count"));
EXPECT_GT(partitioned.at("task_peak_parallelism").get<std::size_t>(), 0U);
EXPECT_GT(partitioned.at("task_graph_duration_ns").get<std::uint64_t>(), 0U);
const auto& partitioned_graph = partitioned.at("controls").at("render_plan");
EXPECT_NE(partitioned_graph.at("topology_id"), single_topology);
EXPECT_EQ(partitioned_graph.at("nodes").size(),
single_graph.at("nodes").size() + 3U);
}
TEST(RenderiveWebGallery, PerformanceCaptureReturnsPlanFrameAnalysisAndStatistics) {
Gallery_Plot_Session session;
ASSERT_EQ(response_json(session.handle(gallery_request(
Gallery_Request_Kind::Open,
open_message("spectrum", "manual")))).at("type"),
"case_state");
const auto requested = invoke_action(session, "capture_frames", 2.0);
ASSERT_EQ(requested.at("type"), "case_state");
const auto& initial_capture = requested.at("telemetry").at("performance_capture");
EXPECT_TRUE(initial_capture.at("controller").at("enabled"));
EXPECT_EQ(initial_capture.at("controller").at("remaining_frame_count"), 2);
ASSERT_EQ(initial_capture.at("sessions").size(), 1U);
EXPECT_EQ(initial_capture.at("sessions").at(0).at("requested_count"), 2);
nlohmann::json rendered;
for (int frame = 0; frame < 2; ++frame) {
ASSERT_EQ(invoke_action(session, "mode_prepare").at("type"), "case_state");
ASSERT_EQ(invoke_action(session, "mode_refresh").at("type"), "case_state");
rendered = invoke_action(session, "mode_render");
ASSERT_EQ(rendered.at("type"), "case_state");
}
const auto& capture = rendered.at("telemetry").at("performance_capture");
EXPECT_FALSE(capture.at("controller").at("enabled"));
ASSERT_EQ(capture.at("sessions").size(), 1U);
const auto& captured = capture.at("sessions").at(0);
EXPECT_EQ(captured.at("captured_count"), 2);
EXPECT_FALSE(captured.at("active"));
ASSERT_EQ(captured.at("frames").size(), 2U);
EXPECT_TRUE(captured.at("summary").contains("render_p95_ns"));
EXPECT_TRUE(captured.at("summary").contains("average_parallelism"));
EXPECT_TRUE(captured.at("summary").contains("scheduler_wait_p95_ns"));
EXPECT_FALSE(captured.at("node_statistics").empty());
EXPECT_FALSE(captured.at("plan_statistics").empty());
EXPECT_FALSE(capture.at("plans").empty());
for (const auto& frame : captured.at("frames")) {
EXPECT_TRUE(frame.contains("frame_id"));
EXPECT_TRUE(frame.contains("render_plan_version"));
EXPECT_TRUE(frame.contains("render_start_ns"));
EXPECT_TRUE(frame.contains("render_end_ns"));
ASSERT_FALSE(frame.at("node_executions").empty());
const auto& execution = frame.at("node_executions").at(0);
EXPECT_TRUE(execution.contains("start_time_ns"));
EXPECT_TRUE(execution.contains("end_time_ns"));
EXPECT_TRUE(execution.contains("worker_id"));
EXPECT_TRUE(execution.contains("status"));
const auto& analysis = frame.at("analysis");
EXPECT_TRUE(analysis.contains("critical_path"));
EXPECT_TRUE(analysis.contains("parallel_overlap_ns"));
EXPECT_TRUE(analysis.contains("workers"));
const auto version = frame.at("render_plan_version");
EXPECT_TRUE(std::any_of(capture.at("plans").begin(), capture.at("plans").end(),
[&](const auto& plan) { return plan.at("version") == version; }));
}
const auto& plan = capture.at("plans").back();
EXPECT_FALSE(plan.at("nodes").empty());
EXPECT_FALSE(plan.at("edges").empty());
EXPECT_TRUE(plan.contains("difference"));
EXPECT_TRUE(plan.at("difference").contains("added_nodes"));
const auto& statistic = captured.at("node_statistics").at(0);
EXPECT_TRUE(statistic.contains("moving_average_ns"));
EXPECT_TRUE(statistic.contains("p50_ns"));
EXPECT_TRUE(statistic.contains("p95_ns"));
EXPECT_TRUE(statistic.contains("p99_ns"));
EXPECT_TRUE(statistic.contains("critical_path_frequency"));
EXPECT_TRUE(statistic.contains("average_scheduler_wait_ns"));
}
TEST(RenderiveWebGallery, AxisSwapAndEveryPlotDirectionAreEditableAndRenderable) {