RFR: 8357959: (bf) ByteBuffer.allocateDirect initialization can result in large TTSP spikes [v7]

Rohitash Kumar duke at openjdk.org
Tue Jun 3 09:50:02 UTC 2025


On Tue, 3 Jun 2025 08:49:47 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Rohitash Kumar has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Address PR Comments (rename bench and reduce max alloc size)
>
> src/java.base/share/classes/java/nio/Bits.java line 260:
> 
>> 258:             offset += len;
>> 259:         }
>> 260:     }
> 
> So this becomes:
> 
> Suggestion:
> 
>     static void setMemory(long srcAddr, long count, byte value) {
>         long offset = 0;
>         while (offset < count) {
>             long len = Math.min(UNSAFE_SET_THRESHOLD, count - offset);
>             UNSAFE.setMemory(srcAddr + offset, len, value);
>             offset += len;
>         }
>     }

It might be trival but isn't it better to keep `len` declaration outside of while loop?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25487#discussion_r2123307761


More information about the nio-dev mailing list