架构微调

This commit is contained in:
2026-08-11 09:41:06 +08:00
parent 462baeca76
commit 996e6f6154
6 changed files with 108 additions and 95 deletions
+36 -28
View File
@@ -841,12 +841,11 @@ TEST(RenderiveWebGallery, ThreeFrameStrategiesExposeTheirRealActionsAndObservers
EXPECT_TRUE(low_telemetry.contains("render_fps"));
ASSERT_TRUE(low_telemetry.contains("low_latency_limit"));
const auto& limit = low_telemetry.at("low_latency_limit");
EXPECT_TRUE(limit.at("consumer_limited").get<bool>());
EXPECT_FALSE(limit.at("consumer_limited").get<bool>());
EXPECT_FALSE(limit.at("frequency_limited").get<bool>());
EXPECT_FALSE(limit.at("paint_limited").get<bool>());
EXPECT_FALSE(limit.at("render_limited").get<bool>());
EXPECT_TRUE(limit.at("paint_limited").get<bool>() || limit.at("render_limited").get<bool>());
EXPECT_EQ(limit.at("target_interval_ns"), 1);
EXPECT_EQ(limit.at("consumer_interval_ns"), 33'333'333);
EXPECT_EQ(limit.at("consumer_interval_ns"), 0);
EXPECT_GT(limit.at("bottleneck_duration_ns").get<std::uint64_t>(), 1U);
EXPECT_TRUE(low_telemetry.at("kernel_observer").contains("paint_lease_wait_ns"));
EXPECT_TRUE(low_telemetry.at("kernel_observer").contains("render_finish_state_wait_ns"));
@@ -939,7 +938,7 @@ TEST(RenderiveWebGallery, LowLatencyStrategyKeepsForegroundResponsiveUnderAggres
"case_state");
ASSERT_EQ(response_json(session.handle(gallery_request(
Gallery_Request_Kind::Patch,
R"({"category":"event","type":"gallery_patch","patch":{"max_render_fps":1000,"pixel_stream_fps":60}})"))).at("type"),
R"({"category":"event","type":"gallery_patch","patch":{"max_render_fps":1000}})"))).at("type"),
"case_state");
ASSERT_TRUE(wait_for_condition([&session] {
@@ -974,35 +973,41 @@ TEST(RenderiveWebGallery, LowLatencyStrategyKeepsForegroundResponsiveUnderAggres
observer.at("limit_state") == "consumer_limited");
}
TEST(RenderiveWebGallery, WebAdapterPublishesGenericConsumerFeedbackToKernelScheduler) {
TEST(RenderiveWebGallery, WebRuntimeMetricsPublishGenericConsumerFeedbackWithoutTransportFpsCap) {
Gallery_Plot_Session session(true);
ASSERT_EQ(response_json(session.handle(gallery_request(
Gallery_Request_Kind::Open, open_message("spectrum", "low_latency")))).at("type"),
"case_state");
const auto patched = response_json(session.handle(gallery_request(
ASSERT_EQ(response_json(session.handle(gallery_request(
Gallery_Request_Kind::Patch,
R"({"category":"event","type":"gallery_patch","patch":{"max_render_fps":1000000000,"pixel_stream_fps":20}})")));
ASSERT_EQ(patched.at("type"), "case_state");
const auto& telemetry = patched.at("telemetry");
const auto& observer = telemetry.at("kernel_observer");
const auto& limit = telemetry.at("low_latency_limit");
R"({"category":"event","type":"gallery_patch","patch":{"max_render_fps":1000000000}})"))).at("type"),
"case_state");
auto observed = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Observe,
R"({"category":"event","type":"gallery_observe","client_metrics":{"transport_fps":20,"presentation_fps":20,"websocket_buffered_bytes":0,"changed_pixel_frames":10,"duplicate_pixel_frames":0,"frame_request_timeout_count":0,"frame_round_trip_ms":500,"display_interval_ms":500,"overwritten_pixel_frames":0,"last_pixel_receive_age_ms":1,"last_pixel_change_age_ms":1}})")));
auto observer = observed.at("telemetry").at("kernel_observer");
auto limit = observed.at("telemetry").at("low_latency_limit");
EXPECT_EQ(observer.at("configured_frequency_hz"), 1'000'000'000.0);
EXPECT_EQ(observer.at("target_interval_ns"), 1);
EXPECT_EQ(observer.at("consumer_interval_ns"), 50'000'000);
EXPECT_EQ(observer.at("next_refresh_interval_ns"), 50'000'000);
EXPECT_EQ(observer.at("consumer_interval_ns"), 500'000'000);
EXPECT_EQ(observer.at("next_refresh_interval_ns"), 500'000'000);
EXPECT_EQ(observer.at("limit_state"), "consumer_limited");
EXPECT_EQ(limit.at("current"), "consumer_limited");
EXPECT_TRUE(limit.at("consumer_limited").get<bool>());
EXPECT_EQ(limit.at("consumer_feedback_source"), "web_pixel_stream");
EXPECT_EQ(limit.at("consumer_interval_ns"), 50'000'000);
EXPECT_EQ(limit.at("scheduler_interval_ns"), 50'000'000);
EXPECT_DOUBLE_EQ(limit.at("scheduler_frequency_hz"), 20.0);
const auto baseline = successful_render_count(session);
ASSERT_TRUE(wait_for_condition([&session, baseline] {
return successful_render_count(session) > baseline;
}));
std::this_thread::sleep_for(std::chrono::milliseconds(250));
EXPECT_LE(successful_render_count(session) - baseline, 9U);
EXPECT_EQ(limit.at("consumer_feedback_source"), "web_runtime");
EXPECT_FALSE(limit.contains("web_pixel_stream_fps"));
observed = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Observe,
R"({"category":"event","type":"gallery_observe","client_metrics":{"transport_fps":120,"presentation_fps":60,"websocket_buffered_bytes":0,"changed_pixel_frames":20,"duplicate_pixel_frames":0,"frame_request_timeout_count":0,"frame_round_trip_ms":2,"display_interval_ms":20,"overwritten_pixel_frames":1,"last_pixel_receive_age_ms":1,"last_pixel_change_age_ms":1}})")));
observer = observed.at("telemetry").at("kernel_observer");
EXPECT_EQ(observer.at("consumer_interval_ns"), 20'000'000);
observed = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Observe,
R"({"category":"event","type":"gallery_observe","client_metrics":{"transport_fps":120,"presentation_fps":120,"websocket_buffered_bytes":0,"changed_pixel_frames":30,"duplicate_pixel_frames":0,"frame_request_timeout_count":0,"frame_round_trip_ms":2,"display_interval_ms":8,"overwritten_pixel_frames":1,"last_pixel_receive_age_ms":1,"last_pixel_change_age_ms":1}})")));
observer = observed.at("telemetry").at("kernel_observer");
EXPECT_EQ(observer.at("consumer_interval_ns"), 8'000'000);
const auto rejected = response_json(session.handle(gallery_request(
Gallery_Request_Kind::Patch,
R"({"category":"event","type":"gallery_patch","patch":{"pixel_stream_fps":30}})")));
EXPECT_EQ(rejected.at("type"), "error");
}
TEST(RenderiveWebGallery, PlaybackStrategyQueuesWithoutAutomaticConsumptionAndReportsEmptyQueue) {
@@ -1090,7 +1095,7 @@ TEST(RenderiveWebGallery, ProductionLowLatencySessionRendersWithoutPixelPulls) {
}));
const auto observed = session.handle(gallery_request(
Gallery_Request_Kind::Observe,
R"({"category":"event","type":"gallery_observe","client_metrics":{"transport_fps":120,"presentation_fps":60,"websocket_buffered_bytes":0,"changed_pixel_frames":17,"duplicate_pixel_frames":3,"frame_request_timeout_count":2,"last_pixel_receive_age_ms":8.5,"last_pixel_change_age_ms":12.5}})"));
R"({"category":"event","type":"gallery_observe","client_metrics":{"transport_fps":120,"presentation_fps":60,"websocket_buffered_bytes":0,"changed_pixel_frames":17,"duplicate_pixel_frames":3,"frame_request_timeout_count":2,"frame_round_trip_ms":4.5,"display_interval_ms":16.7,"overwritten_pixel_frames":5,"last_pixel_receive_age_ms":8.5,"last_pixel_change_age_ms":12.5}})"));
ASSERT_TRUE(observed.has_value());
const auto telemetry = parse_json(observed->payload).at("telemetry");
const auto& performance = telemetry.at("performance");
@@ -1108,6 +1113,9 @@ TEST(RenderiveWebGallery, ProductionLowLatencySessionRendersWithoutPixelPulls) {
EXPECT_EQ(telemetry.at("client_performance").at("changed_pixel_frames"), 17);
EXPECT_EQ(telemetry.at("client_performance").at("duplicate_pixel_frames"), 3);
EXPECT_EQ(telemetry.at("client_performance").at("frame_request_timeout_count"), 2);
EXPECT_DOUBLE_EQ(telemetry.at("client_performance").at("frame_round_trip_ms"), 4.5);
EXPECT_DOUBLE_EQ(telemetry.at("client_performance").at("display_interval_ms"), 16.7);
EXPECT_EQ(telemetry.at("client_performance").at("overwritten_pixel_frames"), 5);
EXPECT_DOUBLE_EQ(telemetry.at("client_performance").at("last_pixel_receive_age_ms"), 8.5);
EXPECT_DOUBLE_EQ(telemetry.at("client_performance").at("last_pixel_change_age_ms"), 12.5);
}
@@ -1185,7 +1193,7 @@ void expect_low_latency_canvas_to_change(std::string_view case_id) {
ASSERT_FALSE(session.handle(Viewport_Resize{{240, 180}}).has_value());
ASSERT_TRUE(session.handle(gallery_request(
Gallery_Request_Kind::Patch,
R"({"category":"event","type":"gallery_patch","patch":{"max_render_fps":120,"pixel_stream_fps":30}})")));
R"({"category":"event","type":"gallery_patch","patch":{"max_render_fps":120}})")));
std::this_thread::sleep_for(std::chrono::milliseconds(90));
const auto first = session.handle(Frame_Request{});