[CELEBORN-2323] Optimize RegisterShuffle for large partition counts#3686
Open
cfmcgrady wants to merge 2 commits into
Open
[CELEBORN-2323] Optimize RegisterShuffle for large partition counts#3686cfmcgrady wants to merge 2 commits into
cfmcgrady wants to merge 2 commits into
Conversation
1. Replace partitionIdList (ArrayList<Integer>) transmission with a
single numPartitions integer via new PbRequestSlotsV2 message type,
eliminating ~10MB protobuf payload for 2M-partition shuffles.
Old PbRequestSlots is preserved for backward compatibility.
2. Optimize SlotsAllocator.roundRobin():
- Pre-compute per-worker usable slots into long[] arrays, replacing
O(N*W) haveUsableSlots() stream calls with O(1) array lookups.
- Replace LinkedList iterator + remove with index-based traversal,
eliminating O(N^2) element shifting overhead that dominated CPU
(90% in flame graph for 2M partitions).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR optimizes the
RegisterShufflepath for large partition counts with two key changes:Replace partition ID list transmission with a single integer
PbRequestSlotsV2protobuf message that transmitsnumPartitions(a singleint32) instead ofpartitionIdList(ArrayList<Integer>).PbRequestSlotsdeserialization path is preserved for backward compatibility with older clients.Optimize
SlotsAllocator.roundRobin()algorithmlong[]arrays via a newcomputeUsableSlots()helper, replacing O(N*W)haveUsableSlots()stream calls with O(1) array lookups.LinkedListcopy + iterator-based removal with direct index-based traversal on the originalArrayList, eliminating the O(N)LinkedListcopy overhead and improving CPU cache locality for 2M-partition scenarios (linked nodes scattered across the heap cause heavy cache misses).Why are the changes needed?
When registering shuffles with very large partition counts (e.g., 2M partitions):
ArrayList<Integer>of 2M partition IDs as protobuf creates ~10MB payloads, wasting network bandwidth and serialization/deserialization CPU. The partition IDs are always a simple 0..N-1 range, so only the count is needed.partitionIdsinto aLinkedListfor O(1) iterator removal, but this introduces O(N) copy overhead and poor cache locality (2M linked nodes scattered across the heap). Additionally, repeatedhaveUsableSlots()stream operations re-scan all disk info for every partition assignment, resulting in O(N*W) overhead. This PR eliminates both bottlenecks by using index-based traversal directly on the original list and pre-computing usable slots per worker.Does this PR resolve a correctness bug?
No. This is a performance optimization.
Does this PR introduce any user-facing change?
No. The optimization is internal to the RegisterShuffle RPC and slot allocation logic. The new
PbRequestSlotsV2message is used for outgoing requests, while the oldPbRequestSlotsmessage is still supported for deserialization (backward compatibility).How was this patch tested?
MasterSuiteupdated to use the newnumPartitionsparameter.ChangePartitionManagerUpdateWorkersSuiteLifecycleManagerCommitFilesSuiteLifecycleManagerDestroySlotsSuiteLifecycleManagerSetupEndpointSuiteLifecycleManagerSuiteLifecycleManagerUnregisterShuffleSuiteShuffleClientSuitenumPartitions: IntreplacingpartitionIdList: ArrayList[Integer]).