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

Generate Raptor transfer cache in parallel #6326

Open
wants to merge 3 commits into
base: dev-2.x
Choose a base branch
from

Conversation

miklcct
Copy link
Contributor

@miklcct miklcct commented Dec 9, 2024

Summary

This makes the Raptor cache generating process run in parallel.

Our GB-wide deployment pre-caches 4 configurations on startup. Before applying this fix, it takes 16 minutes to cache 4 configurations for the whole GB on a 16-core machine:

Dec 09 17:54:06 lemon java[1497422]: 17:54:06.305 INFO [main]  (ConstructApplication.java:242) Creating initial raptor transfer cache progress tracking started.
Dec 09 17:58:31 lemon java[1497422]: 17:58:31.315 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, walk: WalkPreferences{reluctance: 1.68, boardCost: $300}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}}
Dec 09 17:58:31 lemon java[1497422]: 17:58:31.323 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 1 of 4 (25%)
Dec 09 18:02:42 lemon java[1497422]: 18:02:42.391 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, wheelchair, walk: WalkPreferences{reluctance: 1.68, boardCost: $300}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}, wheelchairPreferences: WheelchairPreferences{trip: AccessibilityPreferences{}, stop: AccessibilityPreferences{}, slopeExceededReluctance: 50.0, stairsReluctance: 25.0}}
Dec 09 18:02:42 lemon java[1497422]: 18:02:42.394 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 2 of 4 (50%)
Dec 09 18:06:41 lemon java[1497422]: 18:06:41.853 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, walk: WalkPreferences{reluctance: 1.0, boardCost: $0}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}}
Dec 09 18:06:41 lemon java[1497422]: 18:06:41.855 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 3 of 4 (75%)
Dec 09 18:10:50 lemon java[1497422]: 18:10:50.696 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, wheelchair, walk: WalkPreferences{reluctance: 1.0, boardCost: $0}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}, wheelchairPreferences: WheelchairPreferences{trip: AccessibilityPreferences{}, stop: AccessibilityPreferences{}, slopeExceededReluctance: 50.0, stairsReluctance: 25.0}}
Dec 09 18:10:50 lemon java[1497422]: 18:10:50.698 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 4 of 4 (100%)
Dec 09 18:10:50 lemon java[1497422]: 18:10:50.698 INFO [main]  (ConstructApplication.java:251) Creating initial raptor transfer cache progress tracking complete. 4 done in 16m44s (0 per second).

After applying this patch, it only takes 5 minutes:

Dec 09 18:46:09 lemon java[1500378]: 18:46:09.979 INFO [main]  (ConstructApplication.java:242) Creating initial raptor transfer cache progress tracking started.
Dec 09 18:47:31 lemon java[1500378]: 18:47:31.036 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, walk: WalkPreferences{reluctance: 1.68, boardCost: $300}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}}
Dec 09 18:47:31 lemon java[1500378]: 18:47:31.044 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 1 of 4 (25%)
Dec 09 18:48:46 lemon java[1500378]: 18:48:46.023 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, wheelchair, walk: WalkPreferences{reluctance: 1.68, boardCost: $300}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}, wheelchairPreferences: WheelchairPreferences{trip: AccessibilityPreferences{}, stop: AccessibilityPreferences{}, slopeExceededReluctance: 50.0, stairsReluctance: 25.0}}
Dec 09 18:48:46 lemon java[1500378]: 18:48:46.026 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 2 of 4 (50%)
Dec 09 18:50:02 lemon java[1500378]: 18:50:02.286 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, walk: WalkPreferences{reluctance: 1.0, boardCost: $0}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}}
Dec 09 18:50:02 lemon java[1500378]: 18:50:02.287 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 3 of 4 (75%)
Dec 09 18:51:18 lemon java[1500378]: 18:51:18.349 INFO [main]  (RaptorRequestTransferCache.java:44) Initializing cache with request: StreetRelevantOptions{transferMode: WALK, wheelchair, walk: WalkPreferences{reluctance: 1.0, boardCost: $0}, street: StreetPreferences{drivingDirection: LEFT, accessEgress: AccessEgressPreferences{maxDuration: DurationForStreetMode{default:2h}}}, wheelchairPreferences: WheelchairPreferences{trip: AccessibilityPreferences{}, stop: AccessibilityPreferences{}, slopeExceededReluctance: 50.0, stairsReluctance: 25.0}}
Dec 09 18:51:18 lemon java[1500378]: 18:51:18.352 INFO [main]  (ConstructApplication.java:248) Creating initial raptor transfer cache progress: 4 of 4 (100%)
Dec 09 18:51:18 lemon java[1500378]: 18:51:18.353 INFO [main]  (ConstructApplication.java:251) Creating initial raptor transfer cache progress tracking complete. 4 done in 5m8s (0 per second).

Also, the journey planning response time for a new configuration has been reduced correspondingly from more than 4 minutes to around 1.5 minutes.

Issue

#6312

Unit tests

None. This is a performance improvement only with no externally visible change.

Documentation

N/A

Changelog

Bumping the serialization version id

Not needed

@miklcct miklcct requested a review from a team as a code owner December 9, 2024 19:18
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.81%. Comparing base (20696c1) to head (cded867).
Report is 84 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...thm/raptoradapter/transit/RaptorTransferIndex.java 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6326      +/-   ##
=============================================
+ Coverage      69.79%   69.81%   +0.01%     
- Complexity     17798    17827      +29     
=============================================
  Files           2019     2019              
  Lines          76126    76250     +124     
  Branches        7786     7803      +17     
=============================================
+ Hits           53132    53233     +101     
- Misses         20288    20302      +14     
- Partials        2706     2715       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@t2gran
Copy link
Member

t2gran commented Dec 11, 2024

I think this is going to reduce the throughput slightly. The issue is that one request that require new transfers to be generated will steel processor time from other requests. I am not sure how the affect memory fetches, but It might have a negative effect on running trip searches - at least if a planning request is swapped out in favour of calculating transfers.

The threads also loose log-trace-parameters-propagation and graceful timeout handling.

The parrallel procecing at least need to be feature enabled using OTPFeature.ParallelRouting.isOn().

@optionsome
Copy link
Member

There is also a possibility that these are only computed in parallel before start up but not after server is running. I don't know whether this code is used for both cases or not.

@miklcct
Copy link
Contributor Author

miklcct commented Dec 12, 2024

There is also a possibility that these are only computed in parallel before start up but not after server is running. I don't know whether this code is used for both cases or not.

I specifically need it to compute in parallel in order to make our response time down from 4 minute to 1 minute.

@optionsome optionsome self-requested a review December 12, 2024 15:00
@optionsome
Copy link
Member

Only check the feature flag during run time, not during start-up.

@optionsome optionsome added Optimization The feature is to improve performance. Digitransit Test Feature is under testing in Digitransit environment(s) labels Dec 12, 2024
@optionsome optionsome added this to the 2.7 (next release) milestone Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Digitransit Test Feature is under testing in Digitransit environment(s) Optimization The feature is to improve performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants