-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make Raptor transfer cost calculation done on demand only when it is accessed for caches generated per request #6792
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
base: dev-2.x
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6792 +/- ##
=============================================
+ Coverage 72.15% 72.20% +0.04%
- Complexity 19782 19917 +135
=============================================
Files 2151 2163 +12
Lines 79981 80252 +271
Branches 8061 8107 +46
=============================================
+ Hits 57713 57942 +229
- Misses 19422 19451 +29
- Partials 2846 2859 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f30471b to
338443d
Compare
|
As discussed in the dev meeting, I will add a new feature flag (disabled by default) to enable the use of the new class, otherwise we will keep the original behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but fix the "keep history on the RaptorTransferIndex" so I can verify that there are no changes.
application/src/main/java/org/opentripplanner/framework/application/OTPFeature.java
Outdated
Show resolved
Hide resolved
...rg/opentripplanner/routing/algorithm/raptoradapter/transit/PreCachedRaptorTransferIndex.java
Show resolved
Hide resolved
cdf24f8 to
5ec958b
Compare
...ava/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndexTest.java
Outdated
Show resolved
Hide resolved
...ava/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndexTest.java
Outdated
Show resolved
Hide resolved
...ava/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndexTest.java
Show resolved
Hide resolved
0d4c4ce to
3a4189c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parallell generation of transfers can not be turned of any more:
Old code - missing:
// we want to always parallelize the cache building during the startup
// and only parallelize during runtime requests if the feature flag is on
if (requestSource == RequestSource.SETUP || OTPFeature.ParallelRouting.isOn()) {
stopIndices = stopIndices.parallel();
}
|
Thanks for your comment. |
|
I'm finding it very difficult to verify that the current behaviour has not changed but I compiled the code and ran it on one of my deployments and could not find a problem. |
|
This PR is very difficult to review:
I am unsure what to do. I consider approving this - and be better at making the PRs easier for review in the future. We can discuss this in the meeting tomorrow. |
|
I could live with that risk. |
|
My original intention was to move the implementation to a new class and change the class to be an interface, such that the user of the class would not see any changes. |
|
I'll rewrite the history again to further clarify my intention. |
|
@miklcct Please wait until we have discussed this in tomorrows meeting. |
# Conflicts: # doc/user/Configuration.md
...ava/org/opentripplanner/routing/algorithm/raptoradapter/transit/RaptorTransferIndexTest.java
Outdated
Show resolved
Hide resolved
...org/opentripplanner/routing/algorithm/raptoradapter/transit/OnDemandRaptorTransferIndex.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| @Override | ||
| public Collection<DefaultRaptorTransfer> getForwardTransfers(int stopIndex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this need to be thread safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Java, object assignment is thread safe because it is an atomic operation. There can be race condition here between the check and the assignment but the assignment is always the same value. Will it cause a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you think it is necessary, I can create a lock object for every stop index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this in the dev meeting. This can stay as is. @miklcct can add a comment to the code explaining that this is not fully thread-safe but not worth it to synchronize it.
Co-authored-by: Thomas Gran <[email protected]>
Summary
Do not calculate all the transfers immediately when a Raptor transfer cache is not hit and created as a result of a request. Calculate them only when Raptor requires it.
Issue
This improve the problems reported in #6781 and #6312, but not in all cases.
Unit tests
Added for the classes to ensure that the pre-cached and on-demand implementations both behave as expected.
Documentation
N/A
Changelog
N/A
Bumping the serialization version id
Not needed