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

Local journey planning is extremely slow in a country-wide deployment #6312

Open
miklcct opened this issue Dec 6, 2024 · 0 comments
Open

Comments

@miklcct
Copy link
Contributor

miklcct commented Dec 6, 2024

Expected behavior

OpenTripPlanner should return results in a reasonable time (e.g. 15 seconds) when planning a local journey under any circumstances.

Observed behavior

OpenTripPlanner takes a few minutes to return results whenever a new set of preferences is given on a GB-wide deployment, even if the journey provided is a local journey.

Version of OTP used (exact commit hash or JAR name)

2.7.0-SNAPSHOT

Data sets in use (links to GTFS and OSM PBF files)

A GB-wide dataset containing all public transport (except planes) in the country.

Command line used to start OTP

/home/aubin/jdk/bin/java -jar /home/aubin/opentripplanner/otp-shaded.jar --load --serve /home/aubin/opentripplanner

Router config and graph build config JSON

otp-config.json

{
  "otpFeatures" : {
    "GtfsGraphQlApi" : true,
    "ParallelRouting" : true,
    "TransferConstraints" : false,
    "TransmodelGraphQlApi" : true,
    "ActuatorAPI" : false,
    "Co2Emissions" : false,
    "FaresV2" : false,
    "FlexRouting" : true,
    "SandboxAPIGeocoder" : false,
    "SandboxAPIParkAndRideApi" : true,
    "ConsiderPatternsForDirectTransfers" : true,
    "IncludeEmptyRailStopsInTransfers" : true
  }
}

build-config.json

{
  "areaVisibility" : true,
  "dataImportReport" : true,
  "maxTransferDuration" : "PT15M",
  "multiThreadElevationCalculations" : true,
  "staticBikeParkAndRide" : true,
  "staticParkAndRide" : true,
  "subwayAccessTime" : "0.0",
  "transitModelTimeZone" : "Europe/London",
  "transitServiceEnd" : "P3M",
  "transitServiceStart" : "P-7D",
  "boardingLocationTags" : [ "naptan:AtcoCode", "naptan:NaptanCode" ],
  "osmDefaults" : {
    "osmTagMapping" : "uk",
    "timeZone" : "Europe/London"
  },
  "transferRequests" : [ {
    "drivingDirection" : "left",
    "locale" : "en_GB",
    "numItineraries" : 10,
    "searchWindow" : "PT6H",
    "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
    "transitReluctanceForMode" : { },
    "waitReluctance" : 1.76,
    "accessEgress" : {
      "maxDuration" : "PT2H"
    },
    "transferSlack" : "PT2M",
    "boardSlackForMode" : {
      "rail" : "PT30S",
      "airplane" : "PT30M"
    },
    "walk" : {
      "boardCost" : 300,
      "reluctance" : 1.68
    },
    "bicycle" : {
      "boardCost" : 600
    },
    "wheelchairAccessibility" : {
      "enabled" : false
    }
  }, {
    "drivingDirection" : "left",
    "locale" : "en_GB",
    "numItineraries" : 10,
    "searchWindow" : "PT6H",
    "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
    "transitReluctanceForMode" : { },
    "waitReluctance" : 1.76,
    "accessEgress" : {
      "maxDuration" : "PT2H"
    },
    "transferSlack" : "PT2M",
    "boardSlackForMode" : {
      "rail" : "PT30S",
      "airplane" : "PT30M"
    },
    "walk" : {
      "boardCost" : 300,
      "reluctance" : 1.68
    },
    "bicycle" : {
      "boardCost" : 600
    },
    "wheelchairAccessibility" : {
      "enabled" : true,
      "trip" : {
        "onlyConsiderAccessible" : false,
        "unknownCost" : 600,
        "inaccessibleCost" : 3600
      },
      "stop" : {
        "onlyConsiderAccessible" : false,
        "unknownCost" : 600,
        "inaccessibleCost" : 3600
      },
      "elevator" : {
        "onlyConsiderAccessible" : false
      },
      "inaccessibleStreetReluctance" : 25,
      "maxSlope" : 0.08333,
      "slopeExceededReluctance" : 50,
      "stairsReluctance" : 25
    }
  }, {
    "drivingDirection" : "left",
    "locale" : "en_GB",
    "numItineraries" : 10,
    "searchWindow" : "PT6H",
    "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
    "transitReluctanceForMode" : {
      "TRAM" : 1.0,
      "SUBWAY" : 1.0,
      "RAIL" : 1.0,
      "MONORAIL" : 1.0,
      "BUS" : 1.0,
      "COACH" : 1.0,
      "FERRY" : 1.0,
      "CABLE_CAR" : 1.0,
      "GONDOLA" : 1.0,
      "FUNICULAR" : 1.0,
      "AIRPLANE" : 1.0
    },
    "waitReluctance" : 1.0,
    "accessEgress" : {
      "maxDuration" : "PT2H"
    },
    "transferSlack" : "PT0S",
    "transferPenalty" : 0,
    "boardSlackForMode" : {
      "rail" : "PT30S",
      "airplane" : "PT30M"
    },
    "walk" : {
      "boardCost" : 0,
      "reluctance" : 1.0
    },
    "bicycle" : {
      "reluctance" : 1.0,
      "boardCost" : 600,
      "parking" : {
        "cost" : 0
      },
      "walk" : {
        "reluctance" : 1.0,
        "mountDismountCost" : 0
      },
      "rental" : {
        "keepingAtDestinationCost" : 0
      }
    },
    "car" : {
      "reluctance" : 1.0,
      "parking" : {
        "cost" : 0
      }
    },
    "wheelchairAccessibility" : {
      "enabled" : false
    }
  }, {
    "drivingDirection" : "left",
    "locale" : "en_GB",
    "numItineraries" : 10,
    "searchWindow" : "PT6H",
    "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
    "transitReluctanceForMode" : {
      "TRAM" : 1.0,
      "SUBWAY" : 1.0,
      "RAIL" : 1.0,
      "MONORAIL" : 1.0,
      "BUS" : 1.0,
      "COACH" : 1.0,
      "FERRY" : 1.0,
      "CABLE_CAR" : 1.0,
      "GONDOLA" : 1.0,
      "FUNICULAR" : 1.0,
      "AIRPLANE" : 1.0
    },
    "waitReluctance" : 1.0,
    "accessEgress" : {
      "maxDuration" : "PT2H"
    },
    "transferSlack" : "PT0S",
    "transferPenalty" : 0,
    "boardSlackForMode" : {
      "rail" : "PT30S",
      "airplane" : "PT30M"
    },
    "walk" : {
      "boardCost" : 0,
      "reluctance" : 1.0
    },
    "bicycle" : {
      "reluctance" : 1.0,
      "boardCost" : 600,
      "parking" : {
        "cost" : 0
      },
      "walk" : {
        "reluctance" : 1.0,
        "mountDismountCost" : 0
      },
      "rental" : {
        "keepingAtDestinationCost" : 0
      }
    },
    "car" : {
      "reluctance" : 1.0,
      "parking" : {
        "cost" : 0
      }
    },
    "wheelchairAccessibility" : {
      "enabled" : true,
      "trip" : {
        "onlyConsiderAccessible" : false,
        "unknownCost" : 600,
        "inaccessibleCost" : 3600
      },
      "stop" : {
        "onlyConsiderAccessible" : false,
        "unknownCost" : 600,
        "inaccessibleCost" : 3600
      },
      "elevator" : {
        "onlyConsiderAccessible" : false
      },
      "inaccessibleStreetReluctance" : 25,
      "maxSlope" : 0.08333,
      "slopeExceededReluctance" : 50,
      "stairsReluctance" : 25
    }
  } ],
  "transitFeeds" : [ {
    "type" : "gtfs",
    "feedId" : "GB",
    "source" : "combined_gtfs.zip"
  } ]
}

router-config.json

{
  "routingDefaults" : {
    "drivingDirection" : "left",
    "locale" : "en_GB",
    "numItineraries" : 10,
    "searchWindow" : "PT6H",
    "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
    "transitReluctanceForMode" : { },
    "waitReluctance" : 1.76,
    "accessEgress" : {
      "maxDuration" : "PT2H"
    },
    "transferSlack" : "PT2M",
    "boardSlackForMode" : {
      "rail" : "PT30S",
      "airplane" : "PT30M"
    },
    "walk" : {
      "boardCost" : 300,
      "reluctance" : 1.68
    },
    "bicycle" : {
      "boardCost" : 600
    },
    "wheelchairAccessibility" : {
      "enabled" : false,
      "trip" : {
        "onlyConsiderAccessible" : false,
        "unknownCost" : 600,
        "inaccessibleCost" : 3600
      },
      "stop" : {
        "onlyConsiderAccessible" : false,
        "unknownCost" : 600,
        "inaccessibleCost" : 3600
      },
      "elevator" : {
        "onlyConsiderAccessible" : false
      },
      "inaccessibleStreetReluctance" : 25,
      "maxSlope" : 0.08333,
      "slopeExceededReluctance" : 50,
      "stairsReluctance" : 25
    }
  },
  "timetableUpdates" : {
    "maxSnapshotFrequency" : "PT5S"
  },
  "transit" : {
    "searchThreadPoolSize" : 4,
    "transferCacheRequests" : [ {
      "drivingDirection" : "left",
      "locale" : "en_GB",
      "numItineraries" : 10,
      "searchWindow" : "PT6H",
      "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
      "transitReluctanceForMode" : { },
      "waitReluctance" : 1.76,
      "accessEgress" : {
        "maxDuration" : "PT2H"
      },
      "transferSlack" : "PT2M",
      "boardSlackForMode" : {
        "rail" : "PT30S",
        "airplane" : "PT30M"
      },
      "walk" : {
        "boardCost" : 300,
        "reluctance" : 1.68
      },
      "bicycle" : {
        "boardCost" : 600
      },
      "wheelchairAccessibility" : {
        "enabled" : false
      }
    }, {
      "drivingDirection" : "left",
      "locale" : "en_GB",
      "numItineraries" : 10,
      "searchWindow" : "PT6H",
      "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
      "transitReluctanceForMode" : { },
      "waitReluctance" : 1.76,
      "accessEgress" : {
        "maxDuration" : "PT2H"
      },
      "transferSlack" : "PT2M",
      "boardSlackForMode" : {
        "rail" : "PT30S",
        "airplane" : "PT30M"
      },
      "walk" : {
        "boardCost" : 300,
        "reluctance" : 1.68
      },
      "bicycle" : {
        "boardCost" : 600
      },
      "wheelchairAccessibility" : {
        "enabled" : true,
        "trip" : {
          "onlyConsiderAccessible" : false,
          "unknownCost" : 600,
          "inaccessibleCost" : 3600
        },
        "stop" : {
          "onlyConsiderAccessible" : false,
          "unknownCost" : 600,
          "inaccessibleCost" : 3600
        },
        "elevator" : {
          "onlyConsiderAccessible" : false
        },
        "inaccessibleStreetReluctance" : 25,
        "maxSlope" : 0.08333,
        "slopeExceededReluctance" : 50,
        "stairsReluctance" : 25
      }
    }, {
      "drivingDirection" : "left",
      "locale" : "en_GB",
      "numItineraries" : 10,
      "searchWindow" : "PT6H",
      "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
      "transitReluctanceForMode" : {
        "TRAM" : 1.0,
        "SUBWAY" : 1.0,
        "RAIL" : 1.0,
        "MONORAIL" : 1.0,
        "BUS" : 1.0,
        "COACH" : 1.0,
        "FERRY" : 1.0,
        "CABLE_CAR" : 1.0,
        "GONDOLA" : 1.0,
        "FUNICULAR" : 1.0,
        "AIRPLANE" : 1.0
      },
      "waitReluctance" : 1.0,
      "accessEgress" : {
        "maxDuration" : "PT2H"
      },
      "transferSlack" : "PT0S",
      "transferPenalty" : 0,
      "boardSlackForMode" : {
        "rail" : "PT30S",
        "airplane" : "PT30M"
      },
      "walk" : {
        "boardCost" : 0,
        "reluctance" : 1.0
      },
      "bicycle" : {
        "reluctance" : 1.0,
        "boardCost" : 600,
        "parking" : {
          "cost" : 0
        },
        "walk" : {
          "reluctance" : 1.0,
          "mountDismountCost" : 0
        },
        "rental" : {
          "keepingAtDestinationCost" : 0
        }
      },
      "car" : {
        "reluctance" : 1.0,
        "parking" : {
          "cost" : 0
        }
      },
      "wheelchairAccessibility" : {
        "enabled" : false
      }
    }, {
      "drivingDirection" : "left",
      "locale" : "en_GB",
      "numItineraries" : 10,
      "searchWindow" : "PT6H",
      "modes" : "WALK,RAIL,SUBWAY,TRAM,BUS,COACH,FERRY,AIRPLANE,TROLLEYBUS,CABLE_CAR,GONDOLA,FUNICULAR,MONORAIL,CARPOOL,TAXI",
      "transitReluctanceForMode" : {
        "TRAM" : 1.0,
        "SUBWAY" : 1.0,
        "RAIL" : 1.0,
        "MONORAIL" : 1.0,
        "BUS" : 1.0,
        "COACH" : 1.0,
        "FERRY" : 1.0,
        "CABLE_CAR" : 1.0,
        "GONDOLA" : 1.0,
        "FUNICULAR" : 1.0,
        "AIRPLANE" : 1.0
      },
      "waitReluctance" : 1.0,
      "accessEgress" : {
        "maxDuration" : "PT2H"
      },
      "transferSlack" : "PT0S",
      "transferPenalty" : 0,
      "boardSlackForMode" : {
        "rail" : "PT30S",
        "airplane" : "PT30M"
      },
      "walk" : {
        "boardCost" : 0,
        "reluctance" : 1.0
      },
      "bicycle" : {
        "reluctance" : 1.0,
        "boardCost" : 600,
        "parking" : {
          "cost" : 0
        },
        "walk" : {
          "reluctance" : 1.0,
          "mountDismountCost" : 0
        },
        "rental" : {
          "keepingAtDestinationCost" : 0
        }
      },
      "car" : {
        "reluctance" : 1.0,
        "parking" : {
          "cost" : 0
        }
      },
      "wheelchairAccessibility" : {
        "enabled" : true,
        "trip" : {
          "onlyConsiderAccessible" : false,
          "unknownCost" : 600,
          "inaccessibleCost" : 3600
        },
        "stop" : {
          "onlyConsiderAccessible" : false,
          "unknownCost" : 600,
          "inaccessibleCost" : 3600
        },
        "elevator" : {
          "onlyConsiderAccessible" : false
        },
        "inaccessibleStreetReluctance" : 25,
        "maxSlope" : 0.08333,
        "slopeExceededReluctance" : 50,
        "stairsReluctance" : 25
      }
    } ]
  },
  "updaters" : [ {
    "type" : "real-time-alerts",
    "url" : "file:///home/aubin/opentripplanner/national_rail_gtfsrt.binpb",
    "feedId" : "GB",
    "frequency" : "PT5S"
  }, {
    "type" : "stop-time-updater",
    "url" : "file:///home/aubin/opentripplanner/national_rail_gtfsrt.binpb",
    "feedId" : "GB",
    "frequency" : "PT1S"
  }, {
    "type" : "vehicle-positions",
    "url" : "file:///home/aubin/opentripplanner/national_rail_gtfsrt.binpb",
    "feedId" : "GB",
    "frequency" : "PT10S",
    "fuzzyTripMatching" : false,
    "features" : [ "position", "stop-position", "occupancy" ]
  }, {
    "type" : "vehicle-positions",
    "url" : "https://example.com/redacted",
    "feedId" : "GB",
    "frequency" : "PT10S",
    "fuzzyTripMatching" : false,
    "features" : [ "position", "stop-position", "occupancy" ]
  } ]
}

Steps to reproduce the problem

  1. Run a large deployment (our graph is 3.3 GB, with 12638369 vertices and 31311477 edges in the street graph, and 338357 stops, 114151 patterns and 179965 constrained transfers in the transit graph).
  2. Send a journey planning request to OTP with a set of preferences which hasn't been cached in Raptor yet.

Additional information

I have identified the bottleneck to be the Raptor transfer cache. If a journey planning request does not hit the cache, it will need to go through the whole graph, and that process takes 4 minutes on our 16-core server. It leaves an entry in the server log like the following:
INFO [ForkJoinPool.commonPool-worker-18] (RaptorRequestTransferCache.java:60) Adding runtime request to cache: StreetRelevantOptions{transferMode: WALK, walk: WalkPreferences{speed: 1.39, reluctance: 1.25, boardCost: $124}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}}

I will try to profile it first, and if I can't find an improvement in this process, I will need to add another request parameter to limit the search range during journey planning requests (which is also useful to the user to avoid backtracking, e.g. prevent a Hertfordshire - Hertfordshire journey plan from taking a fast train to London and out on another fast train, which is usually the fastest way to make the journey but is much longer than the crow flies or on a sequence of local buses), which can be fed into the transfer cache generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant