-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Renumber graph nodes after partitioning them #4089
Conversation
9628aee
to
5c61a92
Compare
Some tests are failing, need to investigate those. |
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.
LGTM, but some small open questions
for (auto edge : edge_based_graph.GetAdjacentEdgeRange(node)) | ||
{ | ||
const auto &data = edge_based_graph.GetEdgeData(edge); | ||
max_turn_id = std::max(max_turn_id, data.turn_id); |
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.
Here can be a data race. It can fixed by
max_turn_id
is atomic (bad)- use thread local values
- use
tbb::parallel_reduce
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.
Urg good catch, that was a stupid mistake on my side.
src/partition/renumber.cpp
Outdated
auto target = graph.GetTarget(edge); | ||
if (partition[node] != partition[target]) | ||
{ | ||
border_level[node] = level; |
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.
but why not border_level[node] = std::max(border_level[node], level);
?
or level is always non-decreasing -> assertion border_level[node] <= level;
src/partition/renumber.cpp
Outdated
|
||
for (const auto &partition : partitions) | ||
{ | ||
std::stable_sort( |
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 add in words what is this sort is doing and
src/partition/renumber.cpp
Outdated
} | ||
|
||
auto border_level = getHighestBorderLevel(graph, partitions); | ||
std::stable_sort( |
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.
.. what this sort adjusts after the first ordering.
old_to_new_edge[edge] = new_edge_index++; | ||
} | ||
// and all adjacent empty edges | ||
for (auto edge = EndEdges(node); edge < number_of_edges && isDummy(edge); edge++) |
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.
just don't understand why dummy edges are needed? If it is only to have correct results of GetAdjacentEdgeRange
and EndEdges
then it is better to make an iteration over node_array
directly and remove empty edges.
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.
I mainly wanted the renumber operation to not interfere with the structure of the dynamic graph. Removing the dummy edges would compactify the structure but would have non-obvious side-effects like for example InsertEdge
would now take O(n)
because it needs to resize+copy the edge array and relocate the source node edges.
We might want an additional function shrink_to_fit
or something like that, but I don't think we have good use for it right now.
@TheMarex tests fail for CH algorithms only in cases where MLD ordering is really used, probably some CH data also has to be reordered or data preprocessing must be split between CH and MLD steps EDIT: swapping osrm-backend/features/support/data.js Lines 246 to 247 in 6777b5c
|
Ah good point forgot that running contract before partition is also an option. I'll add some code that detects and |
4745e0c
to
602dd39
Compare
Did some measurements today: The memory access pattern for MLD improves significantly: It is concentrated around the low ids which are the border nodes. For CH we see some improved concentration as well. For MLD this translates into speedups, for CH there is no impact as far as I can tell. Memory accesSome plots that show the node id space on the x-axis and the time-slice on the y-axis. Basically these are snapshots of the accessed graph nodes very 10000 operations. CHMLDRuntimeLeft before renumbering, right after renumbering. These are for random routes on Bayern, measuring the whole HTTP request time with CHMLD |
The only failing test is https://github.com/Project-OSRM/osrm-backend/blob/master/features/testbot/zero-speed-updates.feature#L28 one of the zero-speed segment tests. Curiously it now returns a match. Might be related to the fact that the order in which |
@TheMarex ~22% speedup just from renumbering looks really awesome! I have just few remarks:
|
@oxidase investigated the failing test case:
This yields a path that includes an invalid weight. I don't get how this test case was ever passing. There are only two nodes in the graph, renumbering should not have any effect on the graph structure. Also the rtree snapping is unique in this case since we don't place the coordinates on the nodes but in the middle of the segments. |
@TheMarex idk atm why the response is In the general a problem may occur if source node is a meeting node than a negative weight value of the source node is used to compute
|
@TheMarex is the fix of the failing test here osrm-backend/include/partition/edge_based_graph_reader.hpp Lines 174 to 175 in 5c7288a
|
5c7288a
to
5076ccd
Compare
The new numbering uses the partition information to sort border nodes first to compactify storages that need access indexed by border node ID. We also get an optimized cache performance for free sincr we can also recursively sort the nodes by cell ID. This implements issue #3779.
5076ccd
to
6986153
Compare
Issue
This implements the second part of #3779
Tasklist
.fileIndex
.ebg_node
Requirements / Relations
This PR is rebased on #4056.