Skip to content

SPT with finite, non-zero turn costs much slower #2086

Closed

Description

@karussell

For routing with turn restrictions enabled we have a slow down of approx. 2x and so I would expect a maximum slow down of 2x (because the shortest path exploration is usually the fast part of the isochrone calculation). But it seems that the slow down factor is over 6x even for smaller time limits like 10min:

time curl 'localhost:8989/isochrone?point=52.550732,13.350878&profile=car&time_limit=600'
...
real	0m1,179s
user	0m0,000s
sys	0m0,018s

time curl 'localhost:8989/isochrone?point=52.550732,13.350878&profile=car_no_tc&time_limit=600'
...
real	0m7,464s
user	0m0,010s
sys	0m0,004s

Related to #1978 and #1458.

Activity

  1. karussell commented on Jul 21, 2020

    @karussell
    MemberAuthor

    Strange. I cannot reproduce this on my local machine (4.5s vs. 2.8s) using this pbf. Closing for now.

  2. easbar commented on Jul 21, 2020

    @easbar
    Member

    Keep in mind that if turn costs are enabled the graph exploration is edge-based and so the shortest path tree is larger (contains edges that otherwise would be skipped as they point to already explored nodes). Maybe this could be an explanation?

    See this: https://discuss.graphhopper.com/t/missing-edges-in-spt-response/5586/4

  3. karussell commented on Jul 21, 2020

    @karussell
    MemberAuthor

    so the shortest path tree is larger... Maybe this could be an explanation?

    Not sure if this explains the sometimes big differences.

    For version d621386 I found an example of >5x slow down using the france.pbf (the resulting shape is only slightly different). Bluish is with TC so slightly smaller:

    image

    Logs for visited and consumed nodes:

    2020-07-21 14:26:10.490 [dw-22 - GET /isochrone?point=48.839413,2.351074&profile=car&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 5.5795646, visited nodes:486191, consumed nodes:62233, {time_limit=[400], profile=[car], point=[48.839413,2.351074]}
    2020-07-21 14:26:19.208 [dw-19 - GET /isochrone?point=48.839413,2.351074&profile=car_no_tc&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 1.029165, visited nodes:170438, consumed nodes:35151, {time_limit=[400], profile=[car_no_tc], point=[48.839413,2.351074]}
    
  4. otbutz commented on Jul 21, 2020

    @otbutz
    Contributor

    You could profile the execution using JFR if you're using Java 11 or higher.

    JMC: https://adoptopenjdk.net/jmc.html

  5. easbar commented on Jul 21, 2020

    @easbar
    Member

    the resulting shape is only slightly different

    Yeah but the shortest path trees could still be very different in size? In your example the number of visited nodes is very different (486191 for car vs 170438 for car_no_tc) so to me it seems like the real question is why in one case much less nodes are explored (could be due to better/worse LM heuristic?). Maybe MiniGraphUI could help here :)

  6. michaz commented on Jul 22, 2020

    @michaz
    Member

    Hmm. Seems elusive. Works fine on my machine. Despite lots of visited nodes.

    2020-07-22 10:44:11.757 [dw-21 - GET /isochrone?point=48.839413,2.351074&profile=car_no_tc&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 1.1765695, visited nodes:170247, consumed nodes:21612, {time_limit=[400], profile=[car_no_tc], point=[48.839413,2.351074]}
    2020-07-22 10:44:19.128 [dw-20 - GET /isochrone?point=48.839413,2.351074&profile=car&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 2.435008, visited nodes:432537, consumed nodes:36972, {time_limit=[400], profile=[car], point=[48.839413,2.351074]}
    
    
  7. michaz commented on Jul 22, 2020

    @michaz
    Member

    Am I doing this right?

      datareader.file: ile-de-france-latest.osm.pbf
      graph.flag_encoders: car|turn_costs=true
      graph.location: graphs/ile-de-france/graph
      profiles:
        - name: car_no_tc
          vehicle: car
          weighting: fastest
          turn_costs: false
        - name: car
          vehicle: car
          weighting: fastest
          turn_costs: true
    
  8. easbar commented on Jul 22, 2020

    @easbar
    Member

    The landmark generation probably depends on the size of the map (ile-de-france vs. france)? Which map did you exactly use @karussell? Can we use bayern-190101.osm.pbf or germany-190101.osm.pf maybe as these are the ones we use for benchmarks?

  9. michaz commented on Jul 22, 2020

    @michaz
    Member

    Isochrones aren't using Landmarks...

  10. easbar commented on Jul 22, 2020

    @easbar
    Member

    right... :)

  11. karussell commented on Jul 22, 2020

    @karussell
    MemberAuthor

    Hmm. Seems elusive. Works fine on my machine. Despite lots of visited nodes.

    Thanks for investigating this @michaz. I think I found the problem: we use u_turn_costs: 80 in the config and without that I get the times for car with tc that you get (and the factor is roughly the expected 2x).

    Still, let me try to give you the exact same conditions to reproduce the problem in this issue:

    Then I get:

    2020-07-22 14:07:23.660 [dw-19 - GET /isochrone?point=48.839413,2.351074&profile=car&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 5.3310757, visited nodes:480436, consumed nodes:62789, {time_limit=[400], profile=[car], point=[48.839413,2.351074]}
    2020-07-22 14:07:26.463 [dw-20 - GET /isochrone?point=48.839413,2.351074&profile=car_no_tc&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 1.0640897, visited nodes:170247, consumed nodes:35447, {time_limit=[400], profile=[car_no_tc], point=[48.839413,2.351074]}
    

    For the current master 7fe8944 I get better times but the slow down is unchanged over 6x:

    2020-07-22 14:20:08.707 [dw-21 - GET /isochrone?point=48.839413,2.351074&profile=car&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 4.726675, visited nodes:480436, consumed nodes:38879, {time_limit=[400], profile=[car], point=[48.839413,2.351074]}
    2020-07-22 14:20:19.059 [dw-22 - GET /isochrone?point=48.839413,2.351074&profile=car_no_tc&time_limit=400] INFO  c.g.resources.IsochroneResource - took: 0.68705046, visited nodes:170247, consumed nodes:21612, {time_limit=[400], profile=[car_no_tc], point=[48.839413,2.351074]}
    

    master without U turn costs:

    2020-07-22 14:22:58.176 [dw-20 - GET /isochrone?point=48.839413,2.351074&profile=car&time_limit=400&u_turn_costs=0] INFO  c.g.resources.IsochroneResource - took: 1.8611046, visited nodes:487212, consumed nodes:40412, {time_limit=[400], profile=[car], u_turn_costs=[0], point=[48.839413,2.351074]}
    
  12. changed the title [-]isochrone with turn costs enabled much slower[/-] [+]SPT with turn costs enabled much slower[/+] on Jul 22, 2020
  13. changed the title [-]SPT with turn costs enabled much slower[/-] [+]SPT with finite, non-zero turn costs much slower[/+] on Jul 22, 2020
  14. michaz commented on Jul 22, 2020

    @michaz
    Member

    The described scenario requires many queue update/remove operations, which neither zero nor infinite turn-costs do. ShortestPathTree needs to be optimized for this. Is much faster for me now, needs some more testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions