Skip to content

Conversation

@miklcct
Copy link
Contributor

@miklcct miklcct commented Aug 8, 2025

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

@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

❌ Patch coverage is 47.14286% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.20%. Comparing base (7d31996) to head (a52edcf).
⚠️ Report is 200 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...oradapter/transit/OnDemandRaptorTransferIndex.java 0.00% 34 Missing ⚠️
...thm/raptoradapter/transit/RaptorTransferIndex.java 75.00% 1 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@miklcct miklcct force-pushed the incremental-transfer-calculation branch from f30471b to 338443d Compare August 8, 2025 13:42
@t2gran t2gran added this to the 2.8 (next release) milestone Aug 11, 2025
@miklcct miklcct marked this pull request as ready for review August 13, 2025 12:21
@miklcct miklcct requested a review from a team as a code owner August 13, 2025 12:21
@t2gran t2gran modified the milestones: 2.8, 2.9 (next release) Sep 10, 2025
@miklcct
Copy link
Contributor Author

miklcct commented Sep 11, 2025

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.

@t2gran t2gran added !Optimization The feature is to improve performance. +Skip Changelog This is not a relevant change for a product owner since last release. labels Oct 1, 2025
Copy link
Member

@t2gran t2gran left a 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.

@miklcct miklcct force-pushed the incremental-transfer-calculation branch from cdf24f8 to 5ec958b Compare October 1, 2025 17:23
@miklcct miklcct requested a review from t2gran October 1, 2025 17:24
@miklcct miklcct force-pushed the incremental-transfer-calculation branch from 0d4c4ce to 3a4189c Compare October 6, 2025 11:01
Copy link
Member

@t2gran t2gran left a 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();
    }

@miklcct miklcct requested a review from t2gran October 8, 2025 14:56
@miklcct
Copy link
Contributor Author

miklcct commented Oct 8, 2025

Thanks for your comment.

@leonardehrenfried
Copy link
Member

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.

@t2gran
Copy link
Member

t2gran commented Oct 13, 2025

This PR is very difficult to review:

  • When extracting an interface it is important to rename the class and commit - no other changes should be in that commit.
  • Mistakes, doc and unit-tests added at the end of working with a PR should be rebased into the proper place in the git history. Commits should be atomic containing all changes for a "mini-feature" - the history should not be your work history.
  • Needed refactoring should be extracted into separate commits, and preferable be put first - or sometimes in a separate PR.

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.

@leonardehrenfried
Copy link
Member

I could live with that risk.

@miklcct
Copy link
Contributor Author

miklcct commented Oct 13, 2025

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.

@miklcct
Copy link
Contributor Author

miklcct commented Oct 13, 2025

I'll rewrite the history again to further clarify my intention.

@t2gran
Copy link
Member

t2gran commented Oct 13, 2025

@miklcct Please wait until we have discussed this in tomorrows meeting.

# Conflicts:
#	doc/user/Configuration.md
@miklcct miklcct requested a review from t2gran October 20, 2025 16:56
}

@Override
public Collection<DefaultRaptorTransfer> getForwardTransfers(int stopIndex) {
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@miklcct miklcct requested a review from t2gran October 23, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Optimization The feature is to improve performance. +Skip Changelog This is not a relevant change for a product owner since last release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants