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

Fix performance issues after migration to sol2 3.3.0 #6304

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- API:
- FIXED: Fix inefficient osrm-routed connection handling [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)
- Misc:
- FIXED: Fix performance issue after migration to sol2 3.3.0. [#6304](https://github.com/Project-OSRM/osrm-backend/pull/6304)
- FIXED: Fix bug with reading Set values from Lua scripts. [#6285](https://github.com/Project-OSRM/osrm-backend/pull/6285)
- Build:
- CHANGED: Configure Undefined Behaviour Sanitizer. [#6290](https://github.com/Project-OSRM/osrm-backend/pull/6290)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ if(ENABLE_CONAN)
set(Boost_UNIT_TEST_FRAMEWORK_LIBRARY "${Boost_unit_test_framework_LIB_TARGETS}")

find_package(BZip2 REQUIRED EXACT ${CONAN_BZIP2_VERSION})
find_package(EXPAT REQUIRED EXACT ${CONAN_EXPAT_VERSION})
find_package(EXPAT REQUIRED)
find_package(lua REQUIRED EXACT ${CONAN_LUA_VERSION})
set(LUA_LIBRARIES ${lua_LIBRARIES})

Expand Down
4 changes: 4 additions & 0 deletions include/extractor/extraction_relation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class ExtractionRelationContainer
using RelationIDList = std::vector<ExtractionRelation::OsmIDTyped>;
using RelationRefMap = std::unordered_map<std::uint64_t, RelationIDList>;

ExtractionRelationContainer() = default;
ExtractionRelationContainer(ExtractionRelationContainer &&) = default;
ExtractionRelationContainer(const ExtractionRelationContainer &) = delete;

void AddRelation(ExtractionRelation &&rel)
{
rel.Prepare();
Expand Down
20 changes: 11 additions & 9 deletions src/extractor/scripting_environment_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ void Sol2ScriptingEnvironment::ProcessTurn(ExtractionTurn &turn)
case 2:
if (context.has_turn_penalty_function)
{
context.turn_function(context.profile_table, turn);
context.turn_function(context.profile_table, std::ref(turn));

// Turn weight falls back to the duration value in deciseconds
// or uses the extracted unit-less weight value
Expand All @@ -1108,7 +1108,7 @@ void Sol2ScriptingEnvironment::ProcessTurn(ExtractionTurn &turn)
case 1:
if (context.has_turn_penalty_function)
{
context.turn_function(turn);
context.turn_function(std::ref(turn));

// Turn weight falls back to the duration value in deciseconds
// or uses the extracted unit-less weight value
Expand Down Expand Up @@ -1159,14 +1159,16 @@ void Sol2ScriptingEnvironment::ProcessSegment(ExtractionSegment &segment)
case 4:
case 3:
case 2:
context.segment_function(context.profile_table, segment);
context.segment_function(context.profile_table, std::ref(segment));
break;
case 1:
context.segment_function(segment);
context.segment_function(std::ref(segment));
break;
case 0:
context.segment_function(
segment.source, segment.target, segment.distance, segment.duration);
context.segment_function(std::ref(segment.source),
std::ref(segment.target),
segment.distance,
segment.duration);
segment.weight = segment.duration; // back-compatibility fallback to duration
break;
}
Expand All @@ -1183,14 +1185,14 @@ void LuaScriptingContext::ProcessNode(const osmium::Node &node,
{
case 4:
case 3:
node_function(profile_table, std::cref(node), result, relations);
node_function(profile_table, std::cref(node), std::ref(result), std::cref(relations));
break;
case 2:
node_function(profile_table, std::cref(node), result);
node_function(profile_table, std::cref(node), std::ref(result));
break;
case 1:
case 0:
node_function(std::cref(node), result);
node_function(std::cref(node), std::ref(result));
break;
}
}
Expand Down