Skip to content

Commit

Permalink
Fix performance issues after migration to sol2 3.3.0 (Project-OSRM#6304)
Browse files Browse the repository at this point in the history
* Fix performance issues after migration to sol2 3.3.0
  • Loading branch information
SiarheiFedartsou authored and mattwigway committed Jul 20, 2023
1 parent 21eadf2 commit a3fe567
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- FIXED: Use Boost.Beast to parse HTTP request. [#6294](https://github.com/Project-OSRM/osrm-backend/pull/6294)
- 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)
- CHANGED: Pass osm_node_ids by reference in osrm::updater::Updater class. [#6298](https://github.com/Project-OSRM/osrm-backend/pull/6298)
- FIXED: Fix bug with reading Set values from Lua scripts. [#6285](https://github.com/Project-OSRM/osrm-backend/pull/6285)
- FIXED: Bug in bicycle profile that caused exceptions if there is a highway=bicycle in the data. [#6296](https://github.com/Project-OSRM/osrm-backend/pull/6296)
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

0 comments on commit a3fe567

Please sign in to comment.