artofnothingness / mppic

MIT License
84 stars 19 forks source link

optimizations in compilation and threading #81

Closed SteveMacenski closed 1 year ago

SteveMacenski commented 1 year ago

Partially to clean things up but also compiling with some of these flags seems to help and are the same compiler flags as used in https://romanpoya.medium.com/a-look-at-the-performance-of-expression-templates-in-c-eigen-vs-blaze-vs-fastor-vs-armadillo-vs-2474ed38d982 for comparison eith eigen/xtensor/fastor/etc more or less just assuming they know what they're doing.

While the system gets into the 20s of ms, it spends more time in the teens, so I think it has incremental help. I didn't do formal benchmarking, but its clear from the stream of values coming back to me that these flags improved things.

I haven't looked into it yet, but most of the time that we miss our loop rate, its due to 1 really odd cycle that is high. I suspect that's due to the path handler, so that might be an area to consider for optimization.

padhupradheep commented 1 year ago

Off topic and a very basic question, (sorry)

why aren't we setting a CMAKE_BUILD_TYPE , because as far as I understand, there is no default set. For a much better optimized performance we have to use the RELEASE flag right ? Or is it set somewhere else ?

https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html

artofnothingness commented 1 year ago

Off topic and a very basic question, (sorry)

why aren't we setting a CMAKE_BUILD_TYPE , because as far as I understand, there is no default set. For a much better optimized performance we have to use the RELEASE flag right ? Or is it set somewhere else ?

https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html

it usually comes as an argument

SteveMacenski commented 1 year ago

nav2_package() macro handles that stuff, and sets to release if nothing is specified

  if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to Release as none was specified.")
    set(CMAKE_BUILD_TYPE "Release" CACHE
        STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
      "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
  endif()

Its also where C++17 is set and other related compiler warning flags

  # Default to C++14
  if(NOT CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD 17)
  endif()

  if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC)
  endif()

Among other things