From 0739d9c9f59115325f42be1161ad4d5056ada91b Mon Sep 17 00:00:00 2001 From: harelb Date: Wed, 8 Jul 2026 10:38:58 -0400 Subject: [PATCH 1/2] perf(backend): full PGO solve only on new loop closures have_loopclosures_ is latched forever, so after the first LC every spin ran a full KimeraRpgo batch solve (1.86s x 314 spins for ONE LC in the box_7 run = 41% of backend time), starving the queue and lagging the published DSG by 15-20 min. Solve only when new LC factors arrived; between solves deform with the cached optimizer values (temp values cover not-yet-solved nodes). --- src/backend/backend_module.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/backend/backend_module.cpp b/src/backend/backend_module.cpp index bce80d9e..43c301f7 100644 --- a/src/backend/backend_module.cpp +++ b/src/backend/backend_module.cpp @@ -260,11 +260,25 @@ bool BackendModule::spinOnce(bool force_update) { } timer.reset("backend/spin"); - if ((config.optimize_on_lc && have_loopclosures_) || force_optimize_) { + if ((config.optimize_on_lc && have_new_loopclosures_) || force_optimize_) { optimize(timestamp_ns); } else { updateDsgMesh(timestamp_ns); - UpdateInfo::ConstPtr info(new UpdateInfo{timestamp_ns}); + UpdateInfo::ConstPtr info; + if (have_loopclosures_) { + // no new factors to solve: deform new/active nodes and mesh with the cached + // optimized values; the full solve only runs when new loop closures arrive + info.reset(new UpdateInfo{timestamp_ns, + deformation_graph_->getTempValues(), + deformation_graph_->getValues(), + false, + {}, + deformation_graph_.get(), + nullptr, + mesh_offsets_}); + } else { + info.reset(new UpdateInfo{timestamp_ns}); + } dsg_updater_->callUpdateFunctions(timestamp_ns, info); } From ffb51b67b0c1eb0d851101051fe63129908544e2 Mon Sep 17 00:00:00 2001 From: harelb Date: Wed, 8 Jul 2026 10:40:03 -0400 Subject: [PATCH 2/2] fix(backend): logStatus reads the timers that actually exist backend/optimization and backend/mesh_update were never registered, so dsg_pgmo_status.csv optimize_time/mesh_update_time were always NaN. --- src/backend/backend_module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/backend_module.cpp b/src/backend/backend_module.cpp index 43c301f7..586d2c49 100644 --- a/src/backend/backend_module.cpp +++ b/src/backend/backend_module.cpp @@ -569,8 +569,8 @@ void BackendModule::logStatus() { auto& status = status_log_.back(); const auto& timer = hydra::timing::ElapsedTimeRecorder::instance(); status.last_spin_s = timer.getLastElapsed("backend/spin"); - status.last_opt_s = timer.getLastElapsed("backend/optimization"); - status.last_mesh_update_s = timer.getLastElapsed("backend/mesh_update"); + status.last_opt_s = timer.getLastElapsed("dsg_updater/optimization"); + status.last_mesh_update_s = timer.getLastElapsed("backend/mesh_deformation"); } } // namespace hydra