Skip to content

perf(control): use emplace/emplace_back to avoid temporary object creation#12236

Open
nishikawa-masaki wants to merge 9 commits intoautowarefoundation:mainfrom
nishikawa-masaki:perf/optimize-emplace-usage-control
Open

perf(control): use emplace/emplace_back to avoid temporary object creation#12236
nishikawa-masaki wants to merge 9 commits intoautowarefoundation:mainfrom
nishikawa-masaki:perf/optimize-emplace-usage-control

Conversation

@nishikawa-masaki
Copy link
Copy Markdown
Contributor

@nishikawa-masaki nishikawa-masaki commented Mar 4, 2026

Description

This PR optimizes STL container usage in the control packages to reduce temporary object creation, improving runtime performance and reducing memory overhead.

Specifically, the following changes were made:

  • autoware_collision_detector: Replaced push_back with emplace_back when constructing autoware_utils_geometry::Point2d objects in loops.
  • autoware_pid_longitudinal_controller: Replaced call to push_back with emplace_back for std::pair insertion into the velocity history vector, avoiding the creation of a temporary pair object.

Related links

Parent Issue:

  • None

Private Links:

How was this PR tested?

  • Build passed
  • Existing unit tests passed
    • Non-required test "build-test-tidy-pr / clang-tidy-differential (jazzy) / clang-tidy-differential (pull_request)" fails, but this PR is not responsible for the failure.
  • Evaluator scenario tests passed
    • See "Related links" for the results.

Notes for reviewers

These changes are pure refactoring for performance optimization and do not alter the logic or behavior of the nodes.

Interface changes

None.

Effects on system behavior

None.
Reduced memory churn and potential slight performance improvement in affected loops.

Signed-off-by: nishikawa-masaki <masaki.nishikawa@tier4.jp>
@github-actions github-actions bot added the component:control Vehicle control algorithms and mechanisms. (auto-assigned) label Mar 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@nishikawa-masaki nishikawa-masaki added type:arm64 ARM64 architecture issues or compatibility. type:performance Software optimization and system performance. run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) labels Mar 4, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.48%. Comparing base (72c45df) to head (0dcddd8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
control/autoware_collision_detector/src/node.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12236      +/-   ##
==========================================
+ Coverage   18.55%   19.48%   +0.92%     
==========================================
  Files        1888     1888              
  Lines      129750   129865     +115     
  Branches    45921    48119    +2198     
==========================================
+ Hits        24080    25307    +1227     
- Misses      85854    86056     +202     
+ Partials    19816    18502    -1314     
Flag Coverage Δ *Carryforward flag
daily 20.99% <ø> (+<0.01%) ⬆️ Carriedforward from 64ccc47
daily-cuda 18.56% <ø> (+<0.01%) ⬆️ Carriedforward from 64ccc47
daily-humble-amd64-cuda 18.46% <ø> (-0.08%) ⬇️ Carriedforward from 64ccc47
daily-humble-amd64-nocuda 20.87% <ø> (-0.20%) ⬇️ Carriedforward from 64ccc47
daily-jazzy-amd64-nocuda ?
differential 4.90% <16.66%> (?)
total-cuda 18.56% <ø> (+<0.01%) ⬆️ Carriedforward from 64ccc47
total-humble-cuda 18.45% <ø> (-0.08%) ⬇️ Carriedforward from 64ccc47

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nishikawa-masaki
Copy link
Copy Markdown
Contributor Author

Jazzy CI test "build-test-tidy-pr / clang-tidy-differential (jazzy) / clang-tidy-differential (pull_request)" fails, but it is a known problem with Jazzy and can be ignored (not Required).

This PR is still in Draft state because this PR and #12238 should be tested on Evaluator.

@nishikawa-masaki
Copy link
Copy Markdown
Contributor Author

This PR is still in Draft state because this PR and #12238 should be tested on Evaluator.

The problem that stopped testing with the Evaluator has been fixed.
All of the scenario tests passed. See result.

This PR is ready for reviewing and merging.

@nishikawa-masaki nishikawa-masaki self-assigned this Apr 3, 2026
@nishikawa-masaki
Copy link
Copy Markdown
Contributor Author

The commit history of this PR needs squashing on merging.
I assigned myself as the merger after successful reviewing.

Copy link
Copy Markdown
Contributor

@satoshi-ota satoshi-ota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:control Vehicle control algorithms and mechanisms. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:arm64 ARM64 architecture issues or compatibility. type:performance Software optimization and system performance.

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

3 participants