This commit is contained in:
2026-08-15 19:58:39 +08:00
parent 8bfaeeb265
commit 26bbc29a16
29 changed files with 622 additions and 201 deletions
@@ -138,7 +138,7 @@ TEST(render_dag_test, capture_controller_and_repository_capture_exact_requested_
execution->worker_id = static_cast<std::uint32_t>(slot);
execution->status = Node_Execution_Status::complete;
}
repository.publish(session_id, snapshot, analyze_frame(*plan, *snapshot));
repository.publish(session_id, snapshot, plan, analyze_frame(*plan, *snapshot));
}
const auto session = repository.session(session_id);
@@ -232,3 +232,49 @@ TEST(render_dag_test, concurrent_workers_reserve_exactly_one_capture_slot_each)
EXPECT_EQ(captured.load(std::memory_order_relaxed), requested);
EXPECT_FALSE(controller.state().enabled());
}
TEST(render_dag_test, render_plan_history_has_bounded_retention) {
Render_Plan_History history;
std::vector<Render_Plan_Version> versions;
for (std::uint64_t index = 0; index < 70; ++index) {
Render_Graph_Builder builder;
builder.emplace(1000 + index, 2000 + index, "Node", Render_Node_Kind::prepare);
versions.push_back(history.publish(std::move(builder).finish())->version);
}
EXPECT_FALSE(history.find(versions.front()));
EXPECT_TRUE(history.find(versions.back()));
ASSERT_TRUE(history.current());
EXPECT_EQ(history.current()->version, versions.back());
}
TEST(render_dag_test, capture_repository_retains_only_recent_completed_sessions) {
Capture_Repository repository;
Render_Graph_Builder builder;
builder.emplace(3000, 4000, "Node", Render_Node_Kind::prepare);
Render_Plan_History history;
const auto plan = history.publish(std::move(builder).finish());
for (Capture_Session_Id session_id = 1; session_id <= 20; ++session_id) {
repository.begin_session(session_id, 1);
auto snapshot = std::make_shared<Frame_Snapshot>();
snapshot->frame_id = session_id;
snapshot->render_plan_version = plan->version;
snapshot->render_start_ns = session_id * 100;
snapshot->render_end_ns = snapshot->render_start_ns + 10;
snapshot->node_executions.resize(1);
auto& execution = snapshot->node_executions.front();
execution.node_id = plan->graph.nodes.front().node_id;
execution.ready_time_ns = snapshot->render_start_ns;
execution.start_time_ns = snapshot->render_start_ns;
execution.cpu_end_time_ns = snapshot->render_end_ns;
execution.end_time_ns = snapshot->render_end_ns;
execution.status = Node_Execution_Status::complete;
repository.publish(session_id, snapshot, plan, analyze_frame(*plan, *snapshot));
}
const auto sessions = repository.sessions();
ASSERT_EQ(sessions.size(), 16U);
EXPECT_EQ(sessions.front(), 5U);
EXPECT_EQ(sessions.back(), 20U);
EXPECT_FALSE(repository.session(1));
EXPECT_TRUE(repository.session(20));
}