Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(autoware_ndt_scan_matcher): remove evecs_, evals_ of Leaf for memory efficiency #9281

Merged

Conversation

taisa1
Copy link
Contributor

@taisa1 taisa1 commented Nov 11, 2024

Description

By investigating the memory usage during scan matching, I found that the memory consumption was dominated by std::vector<MultiVoxelGridCovariance<pcl::PointXYZ>::Leaf> in addition to the map itself.

The following figure shows the memory usage when executing autoware's ndt_scan_matcher with sample-map-rosbag. The bottom area corresponds to std::vector<MultiVoxelGridCovariance<pcl::PointXYZ>::Leaf> (7.9MB).
Screenshot from 2024-10-15 18-32-27

The struct Leaf contains three Eigen::Matrix3d, and sizeof(Leaf) is 288, so having this for each voxel may consumes a lot of memory with large maps.

In this PR, I propose to remove evecs_ (Eigen::Matrix3d) and evals_ (Eigen::Vector3d) from Leaf. These variables are only used to calculate cov_ and not be used directly. This will reduce sizeof(Leaf) from 288 to 192.

When tested with sample-map-rosbag, the memory usage of std::vector<MultiVoxelGridCovariance<pcl::PointXYZ>::Leaf> was reduced from 7.9MB to 5.2MB.

Related links

How was this PR tested?

I did a regression test on https://github.com/tier4/ndt_omp and got the following result:

elapsed_milliseconds_ratio_mean=0.478 (current / reference)
The scores are perfectly the same.
OK

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@github-actions github-actions bot added the component:localization Vehicle's position determination in its environment. (auto-assigned) label Nov 11, 2024
Copy link

github-actions bot commented Nov 11, 2024

Thank you for contributing to the Autoware project!

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

Please ensure:

mkquda and others added 2 commits November 11, 2024 12:43
… threshold (autowarefoundation#9279)

fix computation of maximum lane changing length threshold

Signed-off-by: mohammad alqudah <[email protected]>
Signed-off-by: taisa1 <[email protected]>
@taisa1 taisa1 force-pushed the perf_ndt_scan_matcher_shrink_leaf branch from d766f86 to 158928f Compare November 11, 2024 03:43
@github-actions github-actions bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label Nov 11, 2024
…/autoware.universe into perf_ndt_scan_matcher_shrink_leaf
@github-actions github-actions bot removed the component:planning Route planning, decision-making, and navigation. (auto-assigned) label Nov 11, 2024
@SakodaShintaro SakodaShintaro added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Nov 11, 2024
Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 29.22%. Comparing base (6d38b5f) to head (694d80e).
Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
...c/ndt_omp/multi_voxel_grid_covariance_omp_impl.hpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9281      +/-   ##
==========================================
- Coverage   29.23%   29.22%   -0.01%     
==========================================
  Files        1335     1335              
  Lines      102959   102963       +4     
  Branches    39954    39958       +4     
==========================================
- Hits        30102    30093       -9     
- Misses      69976    69995      +19     
+ Partials     2881     2875       -6     
Flag Coverage Δ *Carryforward flag
differential 26.65% <0.00%> (?)
total 29.22% <ø> (-0.02%) ⬇️ Carriedforward from 6d38b5f

*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.

Copy link
Contributor

@SakodaShintaro SakodaShintaro left a comment

Choose a reason for hiding this comment

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

Looks Good To Me
I would like to wait for one more approval before merging.

@atsushi421 atsushi421 merged commit a3b2723 into autowarefoundation:main Nov 12, 2024
42 checks passed
@atsushi421 atsushi421 deleted the perf_ndt_scan_matcher_shrink_leaf branch November 12, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:localization Vehicle's position determination in its environment. (auto-assigned) tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants