Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions rmf_traffic_ros2/src/rmf_traffic_ros2/schedule/MirrorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class MirrorManager::Implementation
rclcpp::TimerBase::SharedPtr update_timer;
rclcpp::TimerBase::SharedPtr redo_query_registration_timer;
rclcpp::TimerBase::SharedPtr reconnect_services_timer;
rclcpp::TimerBase::SharedPtr memory_utilization_timer;
RegisterQueryClient register_query_client;

std::shared_ptr<rmf_traffic::schedule::Mirror> mirror;
Expand Down Expand Up @@ -122,6 +123,19 @@ class MirrorManager::Implementation
{
handle_startup_event(*msg);
});

memory_utilization_timer = node->create_wall_timer(
std::chrono::minutes(5), [this, logger = node->get_logger()]()
{
if (this->mirror)
{
RCLCPP_INFO(
logger,
"Memory footprint: stored waypoints %zu - timeline entries %zu",
this->mirror->waypoints_in_storage(),
this->mirror->entries_in_timeline());
}
});
}

bool reconnect_schedule(
Expand Down
46 changes: 46 additions & 0 deletions rmf_traffic_ros2/src/rmf_traffic_ros2/schedule/Negotiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <rclcpp/logging.hpp>

#include <algorithm>

namespace rmf_traffic_ros2 {
namespace schedule {

Expand Down Expand Up @@ -215,6 +217,8 @@ class Negotiation::Implementation
std::shared_ptr<Worker> worker;
rmf_traffic::Duration timeout = std::chrono::seconds(15);

rclcpp::TimerBase::SharedPtr memory_utilization_timer;

using Repeat = rmf_traffic_msgs::msg::NegotiationRepeat;
using RepeatSub = rclcpp::Subscription<Repeat>;
using RepeatPub = rclcpp::Publisher<Repeat>;
Expand Down Expand Up @@ -319,6 +323,48 @@ class Negotiation::Implementation
// TODO(MXG): Make the QoS configurable
const auto qos = rclcpp::ServicesQoS().reliable().keep_last(1000);

memory_utilization_timer = node.create_wall_timer(
rmf_traffic::time::from_seconds(600.0),
[this]()
{
const std::size_t num_negotiations = this->negotiations.size();
std::vector<std::size_t> counts;
std::size_t i = 0;
for (const auto& [_, negotiation] : this->negotiations)
{
++i;
if (i > 100)
{
// Don't keep counting too long or this will block other
// responsibilities of the program.
break;
}

const std::size_t count = negotiation.room.negotiation.count_tables();
counts.push_back(count);
}

std::sort(counts.begin(), counts.end());
std::stringstream ss;
i = 0;
for (auto r_it = counts.rbegin(); r_it != counts.rend(); ++r_it)
{
if (i > 10)
{
// Don't make the message too large, just give the top 10 counts
break;
}

ss << " [" << *r_it << "]";
}

RCLCPP_INFO(
this->node.get_logger(),
"%zu active negotiations, largest sizes:%s",
num_negotiations,
ss.str().c_str());
});

repeat_sub = node.create_subscription<Repeat>(
NegotiationRepeatTopicName, qos,
[&](const Repeat::UniquePtr msg)
Expand Down
10 changes: 10 additions & 0 deletions rmf_traffic_ros2/src/rmf_traffic_ros2/schedule/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,16 @@ void ScheduleNode::setup_cull_timer()
{
cull_timer = create_wall_timer(
std::chrono::minutes(1), [this]() { cull(); });

memory_utilization_timer = create_wall_timer(
std::chrono::minutes(1), [this]()
{
RCLCPP_INFO(
this->get_logger(),
"Memory footprint: stored waypoints %zu - timeline entries %zu",
this->database->waypoints_in_storage(),
this->database->entries_in_timeline());
});
}

//==============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ class ScheduleNode : public rclcpp::Node
// description versions separately from itinerary versions.
std::size_t last_known_participants_version = 0;
std::size_t current_participants_version = 1;

rclcpp::TimerBase::SharedPtr memory_utilization_timer;
};

} // namespace schedule
Expand Down