-
Notifications
You must be signed in to change notification settings - Fork 60
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
Reduce build time by suppressing template instantiation #1419
base: master
Are you sure you want to change the base?
Conversation
…late-instantiation
…late-instantiation
…late-instantiation
Checklist for reviewers ☑️All references to "You" in the following text refer to the code reviewer.
|
Quality Gate passedIssues Measures |
@@ -54,11 +54,13 @@ ament_export_include_directories(${boost_json_SOURCE_DIR}/include) | |||
file(GLOB ${PROJECT_NAME}_POSIX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/posix/*.cpp) | |||
file(GLOB ${PROJECT_NAME}_SYNTAX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/syntax/*.cpp) | |||
file(GLOB ${PROJECT_NAME}_UTILITY_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/utility/*.cpp) | |||
file(GLOB ${PROJECT_NAME}_READER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/reader/*.cpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort in lexicographic order unless there is a technical reason not to.
|
||
ament_auto_add_library(${PROJECT_NAME} SHARED | ||
${${PROJECT_NAME}_POSIX_SOURCES} | ||
${${PROJECT_NAME}_SYNTAX_SOURCES} | ||
${${PROJECT_NAME}_UTILITY_SOURCES} | ||
${${PROJECT_NAME}_READER_SOURCES} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort in lexicographic order unless there is a technical reason not to.
} | ||
inline namespace reader | ||
{ | ||
auto substitute(std::string attribute, const Scope & scope) -> String; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto substitute(std::string attribute, const Scope & scope) -> String; | |
auto substitute(const std::string & attribute, const Scope & scope) -> String; |
@@ -177,5 +133,4 @@ auto readAttribute(const std::string & name, const Node & node, const Scope & sc | |||
} | |||
} // namespace reader | |||
} // namespace openscenario_interpreter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} // namespace openscenario_interpreter | |
} // namespace openscenario_interpreter | |
extern template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> Boolean; | ||
extern template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> UnsignedShort; | ||
extern template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> UnsignedInteger; | ||
extern template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> Double; | ||
extern template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> String; | ||
extern template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> syntax::Rule; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort in lexicographic order unless there is a technical reason not to.
@@ -36,6 +36,17 @@ | |||
|
|||
namespace openscenario_interpreter | |||
{ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto choice( | ||
const pugi::xml_node & node, | ||
std::unordered_map<std::string, std::function<Object(const pugi::xml_node &)>> callees) -> Object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto choice( | |
const pugi::xml_node & node, | |
std::unordered_map<std::string, std::function<Object(const pugi::xml_node &)>> callees) -> Object; | |
auto choice( | |
const pugi::xml_node & node, | |
const std::unordered_map<std::string, std::function<Object(const pugi::xml_node &)>> & callees) -> Object; |
{ | ||
inline namespace reader | ||
{ | ||
auto substitute(std::string attribute, const Scope & scope) -> String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto substitute(std::string attribute, const Scope & scope) -> String | |
auto substitute(const std::string & attribute, const Scope & scope) -> String |
template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) -> Boolean; | ||
template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> UnsignedShort; | ||
template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> UnsignedInteger; | ||
template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) -> Double; | ||
template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) -> String; | ||
template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) | ||
-> syntax::Rule; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort in lexicographic order unless there is a technical reason not to.
Description
Abstract
This PR reduces the build time of
openscenario_interpreter
by suppressing heavy template instantiation.Background
openscenario_interpreter
heavily relies on templated components. These components are typically instantiated and optimized per translation unit, which can lead to longer build times.Details
Added several explicit instantiations to
readAttribute
and moved thesubstitute()
function used internally to the cpp file. No changes were made to the algorithm itself.Added several explicit instantiations to
readElement
. Additionally, thechoice()
function was made non-template and its implementation was moved to the cpp file. No changes were made to the algorithm itself. Due to this change, the arguments of thechoice()
function have changed from "variadic arguments ofstd::pair
" to "std::unordered_map
," resulting in a slight modification in how the arguments are described in the places wherechoice()
is called. Most of the changes in the diffs are due to this modification.Removed the template specialization declarations in
DistanceCondition
/RelativeDistanceCondition
. There are no impacts on other classes due to this change. With the removal of the declarations, the implementation of thedistance()
function has been moved after the specialization.References
N/A
Destructive Changes
N/A
Known Limitations
N/A