Skip to content

perf: deep packages are swarmed with duplicated libraries in ament_target_dependencies() #541

@VRichardJP

Description

@VRichardJP

Here is a cmake trace when building the autoware_behavior_path_planner:

image

Most Autoware packages rely on ament_auto_* macros to build and export libraries.

This feels a bit like #442, except it's no more ament_libraries_deduplicate's fault (it is rather pretty fast):

image

By adding some log messages here and there, I have found that this package is swarmed by duplicated libraries:

diff --git a/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake b/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake
index 50bb69c..e18e94f 100644
--- a/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake
+++ b/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake
@@ -110,6 +110,10 @@ function(ament_target_dependencies target)
         # otherwise use the classic CMake variables
         list_append_unique(definitions ${${package_name}_DEFINITIONS})
         list_append_unique(include_dirs ${${package_name}_INCLUDE_DIRS})
+        message(STATUS "####################################")
+        message(STATUS "package: ${package_name}")
+        message(STATUS "libraries: ${${package_name}_LIBRARIES}")
+        message(STATUS "####################################")
         foreach(library ${${package_name}_LIBRARIES})
           if(NOT "${${package_name}_LIBRARY_DIRS}" STREQUAL "")
             if(NOT IS_ABSOLUTE ${library} OR NOT EXISTS ${library})

Here is just the log output from a single dependency of autoware_behavior_path_planner:
output.txt

There are 8410 libraries, but only 669 of them are unique.

So the cmake processing is slow simply because ament_target_dependencies loops over way too many duplicated items.

It could be a mistake from Autoware's use of ament_auto_* macros, but it feels strange to find so many duplicates. Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions