Add Concurrent Merge Sort Implementation#7544
Open
anshullakra007 wants to merge 7 commits into
Open
Conversation
anshullakra007
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
July 26, 2026 16:13
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7544 +/- ##
============================================
+ Coverage 80.32% 80.33% +0.01%
- Complexity 7406 7418 +12
============================================
Files 812 813 +1
Lines 23914 23951 +37
Branches 4706 4710 +4
============================================
+ Hits 19208 19242 +34
Misses 3945 3945
- Partials 761 764 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anshullakra007
force-pushed
the
feat/concurrent-merge-sort
branch
from
July 26, 2026 16:47
10d265c to
fc8ab59
Compare
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.
Add Concurrent Merge Sort Implementation
Description
This PR introduces a
ConcurrentMergeSortalgorithm that accelerates the standard divide-and-conquer Merge Sort by distributing sub-array sorting tasks across multiple threads utilizing aThreadPoolExecutor.To prevent the overhead of thread creation and context switching from ruining overall performance, this implementation incorporates a sequential fallback threshold (set to 8,192 elements). Once a sub-array's size drops below this threshold—or when a safe maximum concurrency depth is reached—the algorithm smartly switches to a standard sequential Merge Sort. This design prevents thread starvation deadlocks and ensures optimal CPU resource utilization.
Time & Space Complexity
Testing
Comprehensive and strictly deterministic JUnit 5 tests have been added in
ConcurrentMergeSortTest.javato guarantee reliability:[]) and single-element ([42]) arrays.Random(42)seed for CI determinism) to intentionally exceed the 8,192 sequential threshold, verifying the multithreaded pathways against Java's heavily optimized built-inArrays.sort().Checklist
finallyblock, preventing CI/CD pipeline hangs.