RFR: 8266431: Dual-Pivot Quicksort improvements (Radix sort)

Vladimir Sitnikov vsitnikov at openjdk.org
Wed Sep 24 08:51:51 UTC 2025


On Mon, 22 Sep 2025 20:28:13 GMT, Vladimir Yaroslavskiy <duke at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/DualPivotQuicksort.java line 289:
>> 
>>> 287:              */
>>> 288:             boolean isLargeRandom =
>>> 289: //              size > MIN_RADIX_SORT_SIZE && (sorter == null || bits > 0) &&
>> 
>> Do we need an outcommented line of code?
>
> boolean isLargeRandom =
> //              size > MIN_RADIX_SORT_SIZE && (sorter == null || bits > 0) &&
>                 size > MIN_RADIX_SORT_SIZE && (sorter != null && bits > 0) &&
>                 (a[e1] > a[e2] || a[e2] > a[e3] || a[e3] > a[e4] || a[e4] > a[e5]);
> 
> 
> This code runs Radix sort during parallel sort only.
> If you want to use Radix sort during sequential or parallel sort also,
> you need to switch to the first line.
> 
> Agree, both lines should contain explanations.
> 
> If we agree to move Radix sort out from this PR, these lines go away from here.

Have you considered a `private static final boolean USE_RADIX_SORT_WITH_PARALLEL = false;`? Then we don't need to comment the code, and one could flip the behavior by altering the flag

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27411#discussion_r2375039822


More information about the core-libs-dev mailing list