Allow graph executor tuning from config

This commit is contained in:
tian 2026-03-15 01:59:26 +08:00
parent 53afc006c3
commit a32f86fca1
2 changed files with 13 additions and 1 deletions

View File

@ -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,

View File

@ -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<int>("batch_size", static_cast<int>(batch_size_));
const int budget = exec->ValueOr<int>("run_budget", static_cast<int>(run_budget_));
if (batch > 0 && batch <= 1024) batch_size_ = static_cast<size_t>(batch);
if (budget > 0 && budget <= 4096) run_budget_ = static_cast<size_t>(budget);
}
}
bool Start() {
Stop();