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

Nav 126 re improve performance of raptor #80

Merged
merged 41 commits into from
Jul 25, 2024

Conversation

clukas1
Copy link
Member

@clukas1 clukas1 commented Jul 9, 2024

Improving the performance of the multi day raptor.

This is achieved by creating int based stoptime arrays for all service days based on the trip masks provided by the tripmaskprovider. This stoptime arrays contain additional information to allow jumping between days efficiently.

The array is built up as:

  • Index 0: Earliest Stop Time of entire service day
  • Index 1: Latest Stop Time of entire service day
  • For Each Route: (from Position firstStopTimeIdx of each route)
    • Index 0: Earliest Active Stop Time of Service Day for Route (if any, else NO_TRIP value)
    • Index 1: Latest Active Stop Time of Service Day for Route (if any, else NO_TRIP value)
    • For Each Trip of Route a list of 2 times the length of Stops of the Route Stop Sequence, alternating Arrival/Departure time values.

The StopTimes are created in the new class RaptorCache only known to the Raptor package.

Comparison of Performance:
Before (first Multi Day Raptor implementation only using TripMasks)
NAV-66
After Improvements:
NAV-126

@clukas1 clukas1 added the enhancement New feature or request label Jul 9, 2024
@clukas1 clukas1 requested a review from munterfi July 9, 2024 20:30
@clukas1 clukas1 self-assigned this Jul 9, 2024
@clukas1 clukas1 requested a review from Brunner246 July 9, 2024 20:32
@munterfi
Copy link
Member

Heap memory usage for Switzerland:
image

@munterfi
Copy link
Member

After one request:
http://localhost:8080/routing/connections?sourceStopId=Parent8503059&targetStopId=Parent8516161&datetime=2024-07-09T01:10:00
image

@clukas1
Copy link
Member Author

clukas1 commented Jul 12, 2024

image
Explanation of stop times array

@clukas1 clukas1 changed the base branch from NAV-66-Add-logic-for-multiple-day-connections to main July 12, 2024 19:10
Copy link
Member

@munterfi munterfi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ufff that was a slightly bigger PR :)

Thanks @clukas1, really good work!

Most of my comments are about naming things, but I also have some functional issues:

  • We have a lot of caches now, somehow I feel like we are caching on multiple levels. I would only cache at the outermost level in the StopTimeProvider to have everything in one place.
  • TripMask, ServiceDayMask, RaptorTripMaskProvider, maybe combine them with inner classes so it's clear that they belong together and also the hierarchy between them.
  • Maybe encapsulate the logic for accessing the stop time array in a StopTimeUtils class?

Overall, the service day masking approach in the Raptor is very nice.

Copy link
Member

@munterfi munterfi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @clukas1 for the adjustments!

I found something else, the additional transfers are generated, but not used in the transit service implementation. I am not sure if we can simply remove them from the constructor?

If yes, could you please shortly explain? If no, please fix :)

Except from this, looks good to merge.

munterfi and others added 4 commits July 24, 2024 15:45
…:naviqore/raptor into NAV-126-Re-Improve-Performance-of-Raptor

# Conflicts:
#	src/main/java/ch/naviqore/service/impl/PublicTransitServiceImpl.java
@clukas1
Copy link
Member Author

clukas1 commented Jul 25, 2024

All comments addressed now

@munterfi munterfi self-requested a review July 25, 2024 07:56
Copy link
Member

@munterfi munterfi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @clukas1!

Looks good to merge.

@munterfi munterfi merged commit 2acb28b into main Jul 25, 2024
2 checks passed
@munterfi munterfi deleted the NAV-126-Re-Improve-Performance-of-Raptor branch July 25, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants