RFR: 8356993: ArrayDeque should use Arrays.fill() instead of for() loops [v3]

Archie Cobbs acobbs at openjdk.org
Fri May 16 23:55:57 UTC 2025


On Thu, 15 May 2025 21:04:40 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> Please review this small performance tweak `ArrayDeque`.
>> 
>> `ArrayDeque` has an invariant in which any unused elements in the array must be null. In a couple of places, the code is setting contiguous ranges of elements to null using `for()` loops. This can be both simplified and sped up by using `Arrays.fill()` instead.
>
> Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Blackhole ArrayDeque to ensure it's not ignored by the compiler.

I'm closing the PR because it's gone into low-level optimization details that are beyond me.

However I'm still unclear on whether bulk memory set operations are being fully optimized. By that I mean doing [something like this](https://git.zx2c4.com/glibc/commit/?id=cec3aef32412779e207f825db0d057ebb4628ae8) on arm64 at least. Any insights from the experts would be appreciated.

Thanks for the interesting discussion.

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

PR Comment: https://git.openjdk.org/jdk/pull/25237#issuecomment-2887858521


More information about the core-libs-dev mailing list