修复了一些bug

This commit is contained in:
2026-08-11 08:42:08 +08:00
parent b1fca95250
commit 14a6e97b64
174 changed files with 81 additions and 21867 deletions
+39 -6
View File
@@ -37,6 +37,10 @@ double number_value(const Gallery_State& state, std::string_view id) {
return state_value<double>(state, id);
}
std::uint64_t frequency_interval_ns(double frequency_hz) {
return static_cast<std::uint64_t>(1'000'000'000.0 / frequency_hz);
}
int integer_value(const Gallery_State& state, std::string_view id) {
return static_cast<int>(std::lround(number_value(state, id)));
}
@@ -218,10 +222,18 @@ public:
return automatic_low_latency_ && frame_mode_ == Gallery_Frame_Mode::Low_Latency &&
plot_.view_active();
}
[[nodiscard]] std::uint64_t next_refresh_interval_ns() const {
[[nodiscard]] std::uint64_t kernel_refresh_interval_ns() const {
return plot_.refresh_feedback_snapshot().next_refresh_interval_ns;
}
[[nodiscard]] std::uint64_t web_pixel_interval_ns() const {
return frequency_interval_ns(number_value(state_, "pixel_stream_fps"));
}
[[nodiscard]] std::uint64_t automatic_render_interval_ns() const {
return std::max(kernel_refresh_interval_ns(), web_pixel_interval_ns());
}
void set_client_metrics(double transport_fps, double presentation_fps,
std::uint64_t buffered_bytes,
std::uint64_t changed_pixel_frames,
@@ -645,17 +657,28 @@ public:
if (frame_mode_ == Gallery_Frame_Mode::Low_Latency) {
telemetry["render_fps"] = plot_.max_render_fps();
telemetry["refresh_feedback_hz"] = plot_.refresh_feedback_snapshot().frequency_hz;
const auto kernel_interval_ns = kernel_refresh_interval_ns();
const auto web_interval_ns = web_pixel_interval_ns();
const auto scheduler_interval_ns = std::max(kernel_interval_ns, web_interval_ns);
const auto scheduler_limit_source = web_interval_ns > kernel_interval_ns ?
"web_pixel_stream" : observer.limit_state;
telemetry["low_latency_limit"] = {
{"current", observer.limit_state},
{"current", scheduler_limit_source},
{"kernel_current", observer.limit_state},
{"frequency_limited", observer.limit_state == "frequency_limited"},
{"paint_limited", observer.limit_state == "paint_limited"},
{"render_limited", observer.limit_state == "render_limited"},
{"web_pixel_stream_limited", web_interval_ns > kernel_interval_ns},
{"configured_frequency_hz", observer.frequency_hz},
{"web_pixel_stream_fps", number_value(state_, "pixel_stream_fps")},
{"target_interval_ns", observer.target_interval_ns},
{"paint_duration_ns", observer.paint_duration_ns},
{"render_duration_ns", observer.render_duration_ns},
{"bottleneck_duration_ns", observer.bottleneck_duration_ns},
{"next_refresh_interval_ns", observer.next_refresh_interval_ns}
{"kernel_refresh_interval_ns", kernel_interval_ns},
{"web_pixel_stream_interval_ns", web_interval_ns},
{"scheduler_interval_ns", scheduler_interval_ns},
{"scheduler_frequency_hz", 1'000'000'000.0 / static_cast<double>(scheduler_interval_ns)}
};
}
if (primary_) {
@@ -893,14 +916,24 @@ private:
const double pixel_fps = recent_pixel_rate(pixel_history_, now);
const double pixel_megabytes_per_second = recent_pixel_megabytes_per_second(
pixel_history_, now);
const bool low_latency = frame_mode_ == Gallery_Frame_Mode::Low_Latency;
const auto kernel_interval_ns = low_latency ? kernel_refresh_interval_ns() : 0;
const auto web_interval_ns = low_latency ? web_pixel_interval_ns() : 0;
const auto scheduler_interval_ns = low_latency ?
std::max(kernel_interval_ns, web_interval_ns) : 0;
const nlohmann::json line{
{"event", "gallery_performance"},
{"unix_ms", unix_ms},
{"session_id", session_id_},
{"case", case_id_},
{"frame_mode", frame_mode_name(frame_mode_)},
{"configured_fps", frame_mode_ == Gallery_Frame_Mode::Low_Latency ?
plot_.max_render_fps() : 0.0},
{"configured_fps", low_latency ? plot_.max_render_fps() : 0.0},
{"web_pixel_stream_fps", low_latency ? number_value(state_, "pixel_stream_fps") : 0.0},
{"automatic_scheduler_interval_ns", scheduler_interval_ns},
{"automatic_scheduler_fps", scheduler_interval_ns == 0 ? 0.0 :
1'000'000'000.0 / static_cast<double>(scheduler_interval_ns)},
{"automatic_scheduler_limit_source", !low_latency ? "not_applicable" :
(web_interval_ns > kernel_interval_ns ? "web_pixel_stream" : observer.limit_state)},
{"backend_render_fps", recent_rate(render_history_, now)},
{"pixel_response_fps", pixel_fps},
{"client_transport_fps", client_transport_fps_},
@@ -1527,7 +1560,7 @@ struct Gallery_Plot_Session::Impl {
}
(void)scene->render_latest_frame();
const auto interval = std::chrono::nanoseconds(
std::max<std::uint64_t>(1, scene->next_refresh_interval_ns()));
std::max<std::uint64_t>(1, scene->automatic_render_interval_ns()));
if (next_deadline + interval < cycle_started)
next_deadline = cycle_started;
next_deadline += interval;