You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran the measurement on europe-140101.osm.pbf using Xmx/s29g (and car|fastest profile)
map
num nodes
num edges
num shortcuts
preparation time
average query time
Germany
7.079.980
9.077.508
24.157.642
2.5h
26ms
Europe
38.307.787 (x5.4)
49.581.134 (x5.5)
139.610.530 (x5.8)
10.4h (x4.2)
42ms (x1.6)
The table also shows the relative increase of the different measures from Germany to Europe.
The scaling behavior is quite nice, although the size of the graph is about x5.5 the queries are only x1.6 slower and also the import time increases less than proportional with the size of the graph.
These results are different to the ones reported in the forum here (5days import time), but in the case of the forum it seems like two profiles were imported (fastest and shortest). I haven't checked the import time using the shortest weighting yet, but generally CH does not work as well with the shortest weighting (because the graph is less hierarchichal).
Update: I also added the number of shortcuts, it seems to scale more or less proportional with the size of the graph.
Here is the same measurement for node-based CH (no turn restrictions)
map
num nodes
num edges
num shortcuts
preparation time
average query time
Germany
7.079.980
9.077.508
5.660.979
12min
3ms
Europe
38.307.787 (x5.4)
49.581.134 (x5.5)
35.561.021 (x6.3)
1h12min (x6)
10ms (x3.3)
For Europe the preparation for node-based is about 8.7x faster and the queries about 4x faster than for edge-based. The number of shortcuts is about x4 as high for edge-based.
I think x4 shortcuts and query time is quite reasonable, but what probably could and should be improved is the preparation time. But also note that for Germany the differences are more extreme.
I ran the import for europe with the shortest weighting. The factors show the relation to the values I obtained with the fastest weighting above. The number of shortcuts increases by about 20-30% (for node&edge-based), and the import time increases drastically (x3.2/x4.6), two days for edge-based. Unfortunately I did not get the query times, because the Measurement class uses hard-coded fastest weighting.
Hey @easbar , we are interested in using the edge-based CH for our new algorithm, but especially the number of additional shortcuts and preparation time look like a strain on the servers. Do you have any upcoming ideas or projects for significant improvements? If help is required, we can take a look into the code too.
Cheers
This is something that is certainly in the pipeline for the near future yes. The easiest way to try and change things is playing with the parameters (periodic/lazy/neighbor updates) here (or via corresponding properties flags):
* Determines the maximum number of settled edges for the next search based on the mean number of settled edges and
* the fluctuation in the previous searches. The higher this number the longer the search will last and the more
* witness paths will be found. Assuming a normal distribution for example sigmaFactor = 2 means that about 95% of
* the searches will be within the limit.
*/
privatedoublesigmaFactor = 3.0;
privateintminimumMaxSettledEdges = 100;
privateintsettledEdgeStatsResetInterval = 10_000;
which controls the trade-off between the number of shortcuts and the preparation time. If you want to speed up the preparation and are willing to accept slower queries you should try reducing sigmaFactor first (something between 1 and 3 would be my guess, but I have not tried this too much on maps as large as Europe).
To really make progress here I think much more significant changes are needed, especially regarding the graph representation, like #1067.
Thanks, we can definitely try and tune the parameters. Seeing that there is an increase of 44M to 170M shortcuts, I do not think this will solve our problem, though. I agree that algorithmic/logical changes are needed to significantly improve the performance.
Thanks, we can definitely try and tune the parameters.
Ok, yes any progress you can make with this regard would be interesting
Seeing that there is an increase of 44M to 170M shortcuts,
I doubt that there will be huge improvements in terms of the number of shortcuts. For edge-based there will always be a lot more shortcuts needed than for node-based. But it should be possible to achieve a faster preparation (but using more rather than less memory, also mentioned in #1067).
The memory usage during preparation can be handled. What we definitely need is less prep time, as the current ~2 days for Europe will probably translate to 4 or more days globally, even more on our preprocessing that creates some extras. In addition, we need to run this with at least 2 profiles, meaning double the time and double the size. So out of the three, we definitely need less prep time and as secondary condition smaller size.
As soon as I have some time, I can try some parameter tuning, though at least for node-based CH I did not actually find major improvements.
Thanks!
@HendrikLeuschner, Can you share the results of tuning the parameters ? @easbar, Can the PrepareContractionHierarchies done by multiple cores ? I thave 8 cpu's and only one cpu is calculation the edge based CH. (The prepare.ch.threads is set on 8)
Can the PrepareContractionHierarchies done by multiple cores ? I thave 8 cpu's and only one cpu is calculation the edge based CH. (The prepare.ch.threads is set on 8)
Maybe, but I don't think this trivial to do. The prepare.ch.threads parameter only determines how many preparations are done in parallel (when using multiple vehicles/weightings). For a single preparation we only use one core.
@esabar, my processing with edge_based=true|u_turn_costs=-1 in CH for europe took 1d 11h:10m:16s. I have run 3 different weigthings. INFO [2019-09-05 07:04:27,168] com.graphhopper.routing.ch.PrepareContractionHierarchies: new shortcuts: 127 184 814, initSize:40 226 867, prepare|fastest, periodic:0, lazy:100, neighbor:0, t(total): 44920.67, t(period): 3266.73, t(lazy): 33164.39, t(neighbor): 0.00, t(contr): 8312.85, t(other) : 176.70, dijkstra-ratio: 74.73%, lazy-overhead: 99%, totalMB:55532, usedMB:32065
INFO [2019-09-05 07:04:27,171] com.graphhopper.routing.ch.PrepareContractionHierarchies: took: 44920s, graph now - num edges: 51 692 460, num nodes: 40 226 867, num shortcuts: 127 184 814
INFO [2019-09-05 12:41:27,602] com.graphhopper.routing.ch.PrepareContractionHierarchies: took: 65141s, graph now - num edges: 51 692 460, num nodes: 40 226 867, num shortcuts: 136 829 098
INFO [2019-09-06 04:54:32,932] com.graphhopper.routing.ch.PrepareContractionHierarchies: took: 123526s, graph now - num edges: 51 692 460, num nodes: 40 226 867, num shortcuts: 146 883 308
My test results.
OSM file: russia.osm.pbf 2.9 Gb
Server: 20 GB RAM, CPU - know only that 8 cores
CLICK ME
0-7 rows is master branch (e3ab2ac from 8 Feb)
*0 row is new_eb_ch_exp branch (aaee6d7 from 14 Feb)
*0 launched after some time 0-7 by this time my server began to overload (other applications on the server), so maybe *0 could even better result
** watched not all the time, so this column is not accurate
#
Profile
Mode
Preparation time
**RAM import is completed / max
Request 9300 km Moscow-Vladivostok
Request 1350 km Moscow-Ufa
0
vehicle: car weighting: fastest turn_costs: true u_turn_costs: 60
CH
1 h 10 min
12 / 13.5 Gb
148-155 ms
46-49 ms
1
vehicle: car weighting: fastest
CH
8-9 min
11 Gb
149-166 ms
43-46 ms
2
vehicle: car weighting: fastest turn_costs: true u_turn_costs: 60
LM
7 min
9.4 Gb
6 sec
55-75 ms
3
vehicle: car weighting: fastest
LM
7 min
9.4 / 14 Gb
916-962 ms
51-59 ms
4
vehicle: car weighting: short_fastest turn_costs: true u_turn_costs: 60
CH
1 h
12.3 Gb
151-161 ms
46-59 ms
5
vehicle: car weighting: short_fastest
CH
8 min
9.9 Gb
151-160 ms
46-47 ms
6
vehicle: car weighting: shortest turn_costs: true u_turn_costs: 60
CH
48 min
12.2 Gb
174-185 ms
50-52 ms
7
vehicle: car weighting: custom turn_costs: true u_turn_costs: 60
CH
1 h 6 min
16.2 Gb
161-177 ms
45-60 ms
*0
vehicle: car weighting: fastest turn_costs: true u_turn_costs: 60
Thanks! So edge-based CH import was around 6-8x slower than node-based. But the query time was about the same? Usually this should be a bit slower. The edge-based import on the new branch was around 30% faster than master. At some point I was hoping for more like 40-50%. I am still running some tests for this (will open a separate PR soon).
If I understand you correctly, needs to compare 0 and 2 rows. LM query is slower, especially 9300 km, 1350 km is a bit slower.
If we look at rows 0 and 2 we see that the LM query is much slower than CH and that is expected. And it is also the more slower the longer the route is that is expected as well. But I was actually comparing rows 0 and 1, because CH with turn costs normally results in a slower query time compared to CH without turn costs. Did you enable instructions and maybe path details? Maybe the total query time was not dominated by the pure route calculation time. 43-46ms in row 1 actually seem rather slow to me. If you are curious it would be interesting to know the query time for instructions=false.
Did you enable instructions and maybe path details?
instructions was false.
I will try again to run these tests (0, 1, *0 rows).
PS: I just restarted *0, now it's even faster, result table updated. Maybe the server is not overloaded right now.
But max RAM has increased (up to 17)
We should really provide a JMH benchmark for these kind of things.
We have the Measurement class already which we run for every commit to track the routing and import speed etc. We do this for a map of Germany (~3G) and Bavaria (~0.5G). Would it be better to use JMH for these benchmarks? Maybe, yes. But so far I do not see what kind of improvement we can expect from this that justifies such a migration.
After #2522 I'll close here for now. Not that further improvements are impossible, but we should open another issue if somebody actually wants to work on this.
Activity
easbar commentedon Mar 19, 2019
I ran the measurement on
europe-140101.osm.pbfusingXmx/s29g(andcar|fastestprofile)The table also shows the relative increase of the different measures from Germany to Europe.
The scaling behavior is quite nice, although the size of the graph is about x5.5 the queries are only x1.6 slower and also the import time increases less than proportional with the size of the graph.
These results are different to the ones reported in the forum here (5days import time), but in the case of the forum it seems like two profiles were imported (fastest and shortest). I haven't checked the import time using the shortest weighting yet, but generally CH does not work as well with the shortest weighting (because the graph is less hierarchichal).
Update: I also added the number of shortcuts, it seems to scale more or less proportional with the size of the graph.
karussell commentedon Mar 19, 2019
This sounds nice - thanks!
Do you also have the info regarding node based routing? Like preparation time and query time. Just for comparison on that hardware.
easbar commentedon Mar 19, 2019
Will post once I have it.
easbar commentedon Mar 21, 2019
Here is the same measurement for node-based CH (no turn restrictions)
For Europe the preparation for node-based is about 8.7x faster and the queries about 4x faster than for edge-based. The number of shortcuts is about x4 as high for edge-based.
easbar commentedon Mar 21, 2019
I think x4 shortcuts and query time is quite reasonable, but what probably could and should be improved is the preparation time. But also note that for Germany the differences are more extreme.
karussell commentedon Mar 21, 2019
Thanks a lot!
Indeed, sounds good :)
easbar commentedon Mar 28, 2019
I ran the import for europe with the shortest weighting. The factors show the relation to the values I obtained with the fastest weighting above. The number of shortcuts increases by about 20-30% (for node&edge-based), and the import time increases drastically (x3.2/x4.6), two days for edge-based. Unfortunately I did not get the query times, because the
Measurementclass uses hard-coded fastest weighting.HendrikLeuschner commentedon May 29, 2019
Hey @easbar , we are interested in using the edge-based CH for our new algorithm, but especially the number of additional shortcuts and preparation time look like a strain on the servers. Do you have any upcoming ideas or projects for significant improvements? If help is required, we can take a look into the code too.
Cheers
easbar commentedon May 29, 2019
This is something that is certainly in the pipeline for the near future yes. The easiest way to try and change things is playing with the parameters (periodic/lazy/neighbor updates) here (or via corresponding properties flags):
graphhopper/core/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java
Lines 500 to 507 in ac5326b
Another important parameter is the
sigmaFactorhere:graphhopper/core/src/main/java/com/graphhopper/routing/ch/WitnessPathSearcher.java
Lines 493 to 501 in ac5326b
which controls the trade-off between the number of shortcuts and the preparation time. If you want to speed up the preparation and are willing to accept slower queries you should try reducing
sigmaFactorfirst (something between 1 and 3 would be my guess, but I have not tried this too much on maps as large as Europe).To really make progress here I think much more significant changes are needed, especially regarding the graph representation, like #1067.
HendrikLeuschner commentedon May 29, 2019
Thanks, we can definitely try and tune the parameters. Seeing that there is an increase of 44M to 170M shortcuts, I do not think this will solve our problem, though. I agree that algorithmic/logical changes are needed to significantly improve the performance.
easbar commentedon May 29, 2019
Ok, yes any progress you can make with this regard would be interesting
I doubt that there will be huge improvements in terms of the number of shortcuts. For edge-based there will always be a lot more shortcuts needed than for node-based. But it should be possible to achieve a faster preparation (but using more rather than less memory, also mentioned in #1067).
easbar commentedon May 31, 2019
Are you mostly interested in a faster preparation time, less memory usage during the contraction or a smaller size of the contracted graph ?
HendrikLeuschner commentedon Jun 3, 2019
The memory usage during preparation can be handled. What we definitely need is less prep time, as the current ~2 days for Europe will probably translate to 4 or more days globally, even more on our preprocessing that creates some extras. In addition, we need to run this with at least 2 profiles, meaning double the time and double the size. So out of the three, we definitely need less prep time and as secondary condition smaller size.
As soon as I have some time, I can try some parameter tuning, though at least for node-based CH I did not actually find major improvements.
Thanks!
3 remaining items
benjamin-rty commentedon Sep 4, 2019
@HendrikLeuschner, Can you share the results of tuning the parameters ?
@easbar, Can the
PrepareContractionHierarchiesdone by multiple cores ? I thave 8 cpu's and only one cpu is calculation the edge based CH. (Theprepare.ch.threadsis set on 8)easbar commentedon Sep 4, 2019
Maybe, but I don't think this trivial to do. The
prepare.ch.threadsparameter only determines how many preparations are done in parallel (when using multiple vehicles/weightings). For a single preparation we only use one core.benjamin-rty commentedon Sep 5, 2019
@esabar, thanks for the answer.
I'am processing Europe - car - edgebased on my local machine. I will let you known my results (monday)
benjamin-rty commentedon Sep 10, 2019
@esabar, my processing with
edge_based=true|u_turn_costs=-1inCHfor europe took 1d 11h:10m:16s. I have run 3 different weigthings.INFO [2019-09-05 07:04:27,168] com.graphhopper.routing.ch.PrepareContractionHierarchies: new shortcuts: 127 184 814, initSize:40 226 867, prepare|fastest, periodic:0, lazy:100, neighbor:0, t(total): 44920.67, t(period): 3266.73, t(lazy): 33164.39, t(neighbor): 0.00, t(contr): 8312.85, t(other) : 176.70, dijkstra-ratio: 74.73%, lazy-overhead: 99%, totalMB:55532, usedMB:32065INFO [2019-09-05 07:04:27,171] com.graphhopper.routing.ch.PrepareContractionHierarchies: took: 44920s, graph now - num edges: 51 692 460, num nodes: 40 226 867, num shortcuts: 127 184 814INFO [2019-09-05 12:41:27,602] com.graphhopper.routing.ch.PrepareContractionHierarchies: new shortcuts: 136 829 098, initSize:40 226 867, prepare|shortestfastest, periodic:0, lazy:100, neighbor:0, t(total): 65141.11, t(period): 2963.12, t(lazy): 51612.38, t(neighbor): 0.00, t(contr): 10378.09, t(other) : 187.52, dijkstra-ratio: 79.48%, lazy-overhead: 100%, totalMB:55609, usedMB:44984INFO [2019-09-05 12:41:27,602] com.graphhopper.routing.ch.PrepareContractionHierarchies: took: 65141s, graph now - num edges: 51 692 460, num nodes: 40 226 867, num shortcuts: 136 829 098INFO [2019-09-06 04:54:32,932] com.graphhopper.routing.ch.PrepareContractionHierarchies: new shortcuts: 146 883 308, initSize:40 226 867, prepare|shortest, periodic:0, lazy:100, neighbor:0, t(total): 123526.44, t(period): 2803.39, t(lazy): 105324.03, t(neighbor): 0.00, t(contr): 15198.32, t(other) : 200.70, dijkstra-ratio: 86.03%, lazy-overhead: 102%, totalMB:55664, usedMB:42343INFO [2019-09-06 04:54:32,932] com.graphhopper.routing.ch.PrepareContractionHierarchies: took: 123526s, graph now - num edges: 51 692 460, num nodes: 40 226 867, num shortcuts: 146 883 308INFO [2019-09-06 04:54:32,933] com.graphhopper.reader.osm.GraphHopperOSM: flushing graph CH|motorrty|RAM_STORE|2D|turn_cost|5,14,4,3,3, details:edges:51 692 460(1578MB), nodes:40 226 867(614MB), name:(207MB), geo:309 513 127(1181MB), bounds:-31.2665395,46.67541544903998,30.171007778592582,78.94290117046761, CHGraph|shortest|motorrty|edge_based=true|u_turn_costs=-1, shortcuts:146 883 308, nodesCH:(307MB), CHGraph|fastest|motorrty|edge_based=true|u_turn_costs=-1, shortcuts:127 184 814, nodesCH:(307MB), CHGraph|shortestfastest|motorrty|edge_based=true|u_turn_costs=-1, shortcuts:136 829 098, nodesCH:(307MB), totalMB:55664, usedMB:42428)INFO [2019-09-06 04:57:06,554] com.graphhopper.reader.osm.GraphHopperOSM: flushed graph totalMB:55659, usedMB:44179)easbar commentedon Sep 10, 2019
Thanks! If I may summarize this:
easbar commentedon Sep 10, 2019
Btw if you use finite u-turn costs you might get less shortcuts: #1652 (comment)
IldarKhayrutdinov commentedon Feb 23, 2022
My test results.
OSM file:
russia.osm.pbf2.9 GbServer: 20 GB RAM, CPU - know only that 8 cores
CLICK ME
0-7 rows is master branch (e3ab2ac from 8 Feb)
*0 row is new_eb_ch_exp branch (aaee6d7 from 14 Feb)
*0 launched after some time 0-7 by this time my server began to overload (other applications on the server), so maybe *0 could even better result
** watched not all the time, so this column is not accurate
import is completed / max
Moscow-Vladivostok
Moscow-Ufa
weighting: fastest
turn_costs: true
u_turn_costs: 60
weighting: fastest
weighting: fastest
turn_costs: true
u_turn_costs: 60
weighting: fastest
weighting: short_fastest
turn_costs: true
u_turn_costs: 60
weighting: short_fastest
weighting: shortest
turn_costs: true
u_turn_costs: 60
weighting: custom
turn_costs: true
u_turn_costs: 60
weighting: fastest
turn_costs: true
u_turn_costs: 60
5040 mineasbar commentedon Feb 23, 2022
Thanks! So edge-based CH import was around 6-8x slower than node-based. But the query time was about the same? Usually this should be a bit slower. The edge-based import on the new branch was around 30% faster than master. At some point I was hoping for more like 40-50%. I am still running some tests for this (will open a separate PR soon).
IldarKhayrutdinov commentedon Feb 23, 2022
If I understand you correctly, needs to compare 0 and 2 rows. LM query is slower, especially 9300 km, 1350 km is a bit slower.
easbar commentedon Feb 23, 2022
If we look at rows 0 and 2 we see that the LM query is much slower than CH and that is expected. And it is also the more slower the longer the route is that is expected as well. But I was actually comparing rows 0 and 1, because CH with turn costs normally results in a slower query time compared to CH without turn costs. Did you enable instructions and maybe path details? Maybe the total query time was not dominated by the pure route calculation time. 43-46ms in row 1 actually seem rather slow to me. If you are curious it would be interesting to know the query time for
instructions=false.IldarKhayrutdinov commentedon Feb 23, 2022
ah, really, without turn_costs should be slower.
instructions was false.
I will try again to run these tests (0, 1, *0 rows).
PS: I just restarted *0, now it's even faster, result table updated. Maybe the server is not overloaded right now.
But max RAM has increased (up to 17)
otbutz commentedon Feb 23, 2022
We should really provide a JMH benchmark for these kind of things.
easbar commentedon Feb 23, 2022
We have the Measurement class already which we run for every commit to track the routing and import speed etc. We do this for a map of Germany (~3G) and Bavaria (~0.5G). Would it be better to use JMH for these benchmarks? Maybe, yes. But so far I do not see what kind of improvement we can expect from this that justifies such a migration.
easbar commentedon Feb 25, 2022
After #2522 I'll close here for now. Not that further improvements are impossible, but we should open another issue if somebody actually wants to work on this.