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 `

Re: RFR: 8356995: Provide default methods min(T, T) and max(T, T) in Comparator interface

2025-05-19 Thread Archie Cobbs
On Mon, 19 May 2025 07:25:17 GMT, Tagir F. Valeev wrote: > I'm not sure whether we should specify exactly the behavior in case if the > comparator returns 0. I feel that it could be a useful invariant that > `Comparator.min(a, b)` and `Comparator.max(a, b)` always return different > argument,

Re: JDK-8352891 Performance improvements to ByteArrayOutputStream

2025-05-15 Thread Archie Cobbs
On Thu, May 15, 2025 at 2:02 AM Peter Levart wrote: > On 4/11/25 6:19 PM, Archie Cobbs wrote: > > Sorry if that wasn't clear - I didn't mean power-of-two exponential > > growth, I meant all segments were literally fixed size, like 256 or > > something (or maybe

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 [v3]

2025-05-15 Thread Archie Cobbs
ied 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. - Changes: - all: https://git.openjdk.o

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 [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: 8357531: The `SegmentBulkOperations::fill` method can be improved using overlaps [v5]

2025-05-22 Thread Archie Cobbs
On Thu, May 22, 2025 at 3:31 PM John R Rose wrote: > > Update benchmark to reflect new fill method > > Related discussion at the hardware level: > > https://github.com/openjdk/jdk/pull/25147#issuecomment-2902463076 > This discussion spurred me to ask a dumb question. Apologies in advance, just

Re: RFR: 8357531: The `SegmentBulkOperations::fill` method can be improved using overlaps [v5]

2025-05-23 Thread Archie Cobbs
.wikipedia.org/wiki/Automatic_vectorization > [2] https://youtu.be/rXv2-lN5Xgk?t=1518 > -- > *From:* core-libs-dev on behalf of > Archie Cobbs > *Sent:* Thursday, May 22, 2025 10:58 PM > *To:* John R Rose > *Cc:* core-libs-dev@openjdk.org > *Subject:* Re: RFR: 8357531: The `

Re: Towards a JSON API for the JDK

2025-05-21 Thread Archie Cobbs
On Wed, May 21, 2025 at 11:30 AM Paul Sandoz wrote: > I consider this a “known unknown” (in the words of Mr. Rumsfeld). We would > need to explore this area throughly, which includes the interconnection > with Serialization 2.0, before we really know what we can and should do in > the near and lo

Re: On Period and DateTimeFormatter

2025-06-18 Thread Archie Cobbs
Period is like Duration - they are both "lengths of time", just using different units (so they are both a TemporalAmount). Similar to how LocalDateTime vs. Instant are both "points in time", just using different units (so they are both a Temporal). But you bring up a good point - perhaps Calendar

Re: Best Practice for Busy Waiting in Java

2025-06-15 Thread Archie Cobbs
Just MHO... This is kind of like asking "What's the best way to waste electricity?" It's a nebulous question until you specify what "best" means in this odd scenario -Archie On Sun, Jun 15, 2025 at 11:09 AM Markus KARG wrote: > Recently I was asked by a programmer, what to do if there sim

<    1   2   3