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

2025-05-16 Thread Archie Cobbs
On Thu, 15 May 2025 21:04:40 GMT, Archie Cobbs 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 u

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

2025-05-15 Thread Archie Cobbs
On Thu, 15 May 2025 18:33:22 GMT, Raffaello Giulietti wrote: > Here are many > [exmaples](https://github.com/openjdk/jmh/tree/master/jmh-samples/src/main/java/org/openjdk/jmh/samples) > on how to correctly use JMH. > > A > [blackhole](https://github.com/openjdk/jmh/blob/master/jmh-samples/sr

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

2025-05-15 Thread Archie Cobbs
> 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

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

2025-05-15 Thread Archie Cobbs
On Thu, 15 May 2025 19:53:03 GMT, ExE Boss wrote: > Note that `Arrays.fill(…)` is simply a `for(…)` loop with an additional range > check Interesting... I was assuming that most of the "bulk" methods in `Arrays` were being hand-optimized with special hardware magic (e.g., vector instructions),

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

2025-05-15 Thread ExE Boss
On Thu, 15 May 2025 17:46:39 GMT, Archie Cobbs 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 u

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

2025-05-15 Thread Raffaello Giulietti
On Thu, 15 May 2025 17:56:10 GMT, Archie Cobbs wrote: >> test/jdk/java/util/ArrayDeque/ClearBenchmarkTestJMH.java line 64: >> >>> 62: @Measurement(iterations = 10) >>> 63: @Warmup(iterations = 3) >>> 64: public void fillAndClear() { >> >> I think you need to return the collection or

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

2025-05-15 Thread Archie Cobbs
On Thu, 15 May 2025 17:50:30 GMT, Rémi Forax wrote: > I think you need to return the collection or send it to a BlackHole I'm fairly new to the benchmark game so I would not be surprised if this is broken. Previously I was adding them to a list but that caused OOMs. Can you clarify what you m

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

2025-05-15 Thread Rémi Forax
On Thu, 15 May 2025 17:46:39 GMT, Archie Cobbs 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 u

Re: RFR: 8356993: ArrayDeque should use Arrays.fill() instead of for() loops

2025-05-15 Thread Archie Cobbs
On Wed, 14 May 2025 19:37:37 GMT, Archie Cobbs 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

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

2025-05-15 Thread Archie Cobbs
> 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

Re: RFR: 8356993: ArrayDeque should use Arrays.fill() instead of for() loops

2025-05-15 Thread Roger Riggs
On Wed, 14 May 2025 19:37:37 GMT, Archie Cobbs 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

Re: RFR: 8356993: ArrayDeque should use Arrays.fill() instead of for() loops

2025-05-15 Thread Archie Cobbs
On Thu, 15 May 2025 06:07:06 GMT, Alan Bateman wrote: > Are you planning to add some JMH benchmarks to go with this? I wasn't planning to, but I'm inferring from your question that you'd prefer to see one. Which also makes me curious. I'd be shocked if this were slower, but even if not, I won

Re: RFR: 8356993: ArrayDeque should use Arrays.fill() instead of for() loops

2025-05-14 Thread Alan Bateman
On Wed, 14 May 2025 19:37:37 GMT, Archie Cobbs 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

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

2025-05-14 Thread Archie Cobbs
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 `