feat: debug metrics updateMap — lock_wait/lock_hold, window cells, empty cycles
debug_level (0/1/2) trên báo cáo performance định kỳ: 0 giữ nguyên output cũ; 1 thêm lock_wait (tranh chấp mutex với planner) tách khỏi lock_hold (việc của chính costmap), kích thước window update và số cycle rỗng — cycle rỗng giờ vẫn được đếm + report nên costmap idle (global) không còn biến mất khỏi log; 2 thêm per-layer bounds_grow [m^2] chỉ mặt layer nào nở vùng update. Số đo sim: lock_wait chiếm 75-90% cycle local costmap khi PRIEST solve (median 7.5 ms, max 53 ms) trong khi lock_hold chỉ ~1.8 ms — căn cứ trực tiếp cho snapshot API ở commit sau. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,12 @@ public:
|
||||
|
||||
void setPerformanceMetrics(bool enabled, double reporting_period_seconds);
|
||||
|
||||
/** @brief Debug verbosity for the periodic performance report.
|
||||
* 0 keeps the legacy output untouched; 1 adds lock-wait/hold, update-window
|
||||
* size and empty-cycle counters; 2 adds per-layer bounds-growth lines.
|
||||
* Only effective while performance metrics are enabled. */
|
||||
void setDebugLevel(int level);
|
||||
|
||||
inline const std::string& getGlobalFrameID() const noexcept
|
||||
{
|
||||
return global_frame_;
|
||||
@@ -165,6 +171,10 @@ private:
|
||||
std::uint64_t costs_nanoseconds = 0;
|
||||
std::uint64_t bounds_calls = 0;
|
||||
std::uint64_t costs_calls = 0;
|
||||
// debug_level >= 2: how much this layer grew the update rect [m^2],
|
||||
// clamped to the map extent so the inflation full-map request stays finite
|
||||
double bounds_grow_m2_sum = 0.0;
|
||||
double bounds_grow_m2_max = 0.0;
|
||||
};
|
||||
|
||||
void resetPerformanceMetrics();
|
||||
@@ -188,12 +198,22 @@ private:
|
||||
|
||||
bool performance_metrics_enabled_ = false;
|
||||
double performance_metrics_period_seconds_ = 5.0;
|
||||
int debug_level_ = 0;
|
||||
std::chrono::steady_clock::time_point performance_window_start_;
|
||||
std::uint64_t performance_cycle_nanoseconds_ = 0;
|
||||
std::uint64_t performance_reset_nanoseconds_ = 0;
|
||||
std::uint64_t performance_cycles_ = 0;
|
||||
std::vector<std::uint64_t> performance_cycle_samples_;
|
||||
std::vector<LayerPerformance> layer_performance_;
|
||||
// debug_level >= 1: master-mutex acquisition time is the contention signal
|
||||
// (planners hold the same mutex while reading costs), hold time is our own
|
||||
// cost; empty cycles are updates that found no dirty bounds and did no work.
|
||||
std::uint64_t lock_wait_nanoseconds_ = 0;
|
||||
std::uint64_t lock_wait_max_nanoseconds_ = 0;
|
||||
std::uint64_t lock_hold_nanoseconds_ = 0;
|
||||
std::uint64_t window_cells_sum_ = 0;
|
||||
std::uint64_t window_cells_max_ = 0;
|
||||
std::uint64_t performance_empty_cycles_ = 0;
|
||||
};
|
||||
|
||||
} // namespace robot_costmap_2d
|
||||
|
||||
Reference in New Issue
Block a user