From a32f86fca109a82b283a67bdacfd2234dd2284f1 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sun, 15 Mar 2026 01:59:26 +0800 Subject: [PATCH] Allow graph executor tuning from config --- configs/sample_person_shoe_two_stage_balanced.json | 5 +++++ src/graph_manager.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configs/sample_person_shoe_two_stage_balanced.json b/configs/sample_person_shoe_two_stage_balanced.json index 6977bf5..f258688 100644 --- a/configs/sample_person_shoe_two_stage_balanced.json +++ b/configs/sample_person_shoe_two_stage_balanced.json @@ -6,6 +6,10 @@ "graphs": [ { "name": "person_shoe_two_stage_balanced", + "executor": { + "batch_size": 2, + "run_budget": 8 + }, "nodes": [ { "id": "in", @@ -139,6 +143,7 @@ "type": "publish", "role": "filter", "enable": true, + "cpu_affinity": [7], "codec": "h264", "fps": 30, "bitrate_kbps": 2000, diff --git a/src/graph_manager.cpp b/src/graph_manager.cpp index 0de6f06..c309a28 100644 --- a/src/graph_manager.cpp +++ b/src/graph_manager.cpp @@ -199,7 +199,14 @@ bool EffectiveQueueForEdge(const ParsedEdge& e, const SimpleJson* from_node_queu class Graph::Executor { public: explicit Executor(Graph& g) - : g_(g), batch_size_(DefaultGraphBatchSize()), run_budget_(DefaultGraphRunBudget()) {} + : g_(g), batch_size_(DefaultGraphBatchSize()), run_budget_(DefaultGraphRunBudget()) { + if (const SimpleJson* exec = g_.graph_cfg_.Find("executor"); exec && exec->IsObject()) { + const int batch = exec->ValueOr("batch_size", static_cast(batch_size_)); + const int budget = exec->ValueOr("run_budget", static_cast(run_budget_)); + if (batch > 0 && batch <= 1024) batch_size_ = static_cast(batch); + if (budget > 0 && budget <= 4096) run_budget_ = static_cast(budget); + } + } bool Start() { Stop();