Skip to content

Conversation

@yashmayya
Copy link
Contributor

  • Useful for query routing strategies that require knowing the ideal state replica ID for each segment's instance candidates.

@yashmayya yashmayya added the query label Feb 2, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.14%. Comparing base (77a3dd6) to head (8f348a7).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...ing/instanceselector/SegmentInstanceCandidate.java 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17619      +/-   ##
============================================
- Coverage     63.15%   63.14%   -0.01%     
- Complexity     1479     1498      +19     
============================================
  Files          3173     3173              
  Lines        189917   190109     +192     
  Branches      29064    29070       +6     
============================================
+ Hits         119935   120044     +109     
- Misses        60658    60747      +89     
+ Partials       9324     9318       -6     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-11 63.11% <96.55%> (-0.03%) ⬇️
java-21 63.10% <96.55%> (+7.61%) ⬆️
temurin 63.14% <96.55%> (-0.01%) ⬇️
unittests 63.14% <96.55%> (-0.01%) ⬇️
unittests1 55.54% <ø> (+0.01%) ⬆️
unittests2 34.01% <96.55%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@yashmayya yashmayya marked this pull request as ready for review February 3, 2026 03:10
Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

LGTM. Let's try to reduce the overhead of map access

// Build mapping from instance to position in ideal state (ideal state replica ID)
Map<String, Integer> instanceToIdealStateReplicaId = new HashMap<>();
int idealStateReplicaId = 0;
for (String instance : sortedIdealStateMap.keySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we always loop over IS, we should be able to reduce map lookup by tracking the iteration while looping over IS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't always loop over IS though - see these two cases:

  • (externalViewInstanceStateMap == null) and (newSegmentCreationTimeMs == null)
  • (externalViewInstanceStateMap != null) and (newSegmentCreationTimeMs == null) (only loop over online instances).

Copy link
Contributor

Choose a reason for hiding this comment

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

onlineInstances are also computed via looping over IS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm yes but that would duplicate the logic in three different places for (IMO) little benefit (since these maps would be tiny in size - just the # of replicas per segment). Also this logic is not in the query hot path.

Copy link
Contributor

Choose a reason for hiding this comment

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

It will introduce a per segment short-lived map and one extra map lookup per segment-instance pair. Let me try if it is easy to avoid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, I've updated the logic to avoid the short-lived maps per segment and re-use the same loops.

@yashmayya yashmayya force-pushed the ideal-state-replica-group-routing branch from 822df08 to 8a2f985 Compare February 4, 2026 23:46
@yashmayya yashmayya merged commit 82b7d18 into apache:master Feb 5, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants