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

Optimize likelihood field model runtime performance #199

Merged
merged 2 commits into from
May 31, 2023

Conversation

glpuga
Copy link
Collaborator

@glpuga glpuga commented May 26, 2023

Proposed changes

A number of optimizations to functions in the tightest loops of the Likelihood Sensor model.

Type of change

  • 🐛 Bugfix (change which fixes an issue)
  • 🚀 Feature (change which adds functionality)
  • 📚 Documentation (change which fixes or extends documentation)

Checklist

  • Lint and unit tests (if any) pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All commmits have been signed for DCO

Additional comments

This is working draft. The pre-cubing of the likelihood values broke tests, I haven't yet spent time fixing them.

Results

All performance evaluations were performed on a Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz.

Comparison of pre and post optimization performance

optimized_vs_nonoptimized

Pre-optimization flamegraph:

pre-optimization

Post-optimization flamegraph:

post-optimization

Optimized code vs. Nav2 AMCL

All three (Beluga multi-threaded, Beluga single-threaded and Nav2 AMCL):

optimized_vs_amcl_all

Closer detail of Beluga single-threaded vs. Nav2 AMCL:

optimized_vs_amcl_seq

Copy link
Member

@nahueespinosa nahueespinosa left a comment

Choose a reason for hiding this comment

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

@glpuga Nice!

beluga/include/beluga/sensor/data/regular_grid.hpp Outdated Show resolved Hide resolved
@nahueespinosa nahueespinosa changed the title Micro-optimizations on the Likelihood Sensor model runtime performance Optimize likelihood field model runtime performance May 26, 2023
@nahueespinosa nahueespinosa added enhancement New feature or request cpp Related to C++ code labels May 26, 2023
@glpuga glpuga force-pushed the glpuga/test_micro_optimizations branch 4 times, most recently from 581a209 to 0f20b5c Compare May 26, 2023 18:22
@glpuga glpuga marked this pull request as ready for review May 26, 2023 18:23
Copy link
Collaborator

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

Nice!

beluga/include/beluga/sensor/data/regular_grid.hpp Outdated Show resolved Hide resolved
beluga/include/beluga/sensor/data/regular_grid.hpp Outdated Show resolved Hide resolved
beluga/include/beluga/sensor/data/regular_grid.hpp Outdated Show resolved Hide resolved
beluga/include/beluga/sensor/likelihood_field_model.hpp Outdated Show resolved Hide resolved
@glpuga glpuga force-pushed the glpuga/test_micro_optimizations branch from 33c06a8 to 5ea065b Compare May 27, 2023 01:18
@glpuga
Copy link
Collaborator Author

glpuga commented May 27, 2023

The code after review changes still shows an advantage over Nav2 AMCL.

All three (Beluga multi-threaded, Beluga single-threaded and Nav2 AMCL):

beluga_vs_amcl_multithreaded

Closer detail of Beluga single-threaded vs. Nav2 AMCL (log scale):

beluga_vs_amcl

Closer detail of Beluga single-threaded vs. Nav2 AMCL (linear scale):

beluga_vs_amcl_linear

@glpuga glpuga force-pushed the glpuga/test_micro_optimizations branch from 08fd84c to ea65cdb Compare May 30, 2023 00:17
Signed-off-by: Gerardo Puga <glpuga@ekumenlabs.com>
@glpuga glpuga merged commit 3042aac into main May 31, 2023
@glpuga glpuga deleted the glpuga/test_micro_optimizations branch May 31, 2023 00:59
glpuga added a commit that referenced this pull request Jun 4, 2023
Adds an updated report including the following changes from the last:

- Includes the changes merged in #195 #199 #200 #207 
- Measured using the 1x replay speed to prevent distortions to the CPU
results
- Fixes typos in configuration files, found during review

Signed-off-by: Gerardo Puga <glpuga@ekumenlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Related to C++ code enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants