autowarefoundation / autoware.universe

https://autowarefoundation.github.io/autoware.universe/
Apache License 2.0
888 stars 574 forks source link

Replace `ostream` to lightweight ones in `RunOutModule` #7111

Closed veqcc closed 1 month ago

veqcc commented 1 month ago

Checklist

Description

Currently, 15~20% of CPU time is comsumed by ostream in RunOutModule. See the following flamegraph: The purple ones are related to ostream Screenshot from 2024-05-24 13-23-48

ostream is used here: https://github.com/autowarefoundation/autoware.universe/blob/583cd8518bb9de6ebe334fe87c5e4cd8de62da3b/planning/motion_velocity_smoother/src/smoother/analytical_jerk_constrained_smoother/velocity_planning_utils.cpp#L201C3-L208C101

// for debug
  std::stringstream ss;
  for (unsigned int i = 0; i < ts.size(); ++i) {
    ss << "t: " << ts.at(i) << ", x: " << xs.at(i) << ", v: " << vs.at(i) << ", a: " << as.at(i)
       << ", j: " << js.at(i) << std::endl;
  }
  RCLCPP_DEBUG(
    rclcpp::get_logger("velocity_planning_utils"), "Calculate stop velocity. %s", ss.str().c_str());

Purpose

Performance improvement

Possible approaches

If it is only for debugging, consider eliminating them. Or, avoid using them in release builds.

Definition of done

ostream is eliminated from RunOutModule in release builds.

rej55 commented 1 month ago

Thank you! I created the PR. Could you see it? https://github.com/autowarefoundation/autoware.universe/pull/7131