mapConcurrent() with InterruptedException

2025-01-03 Thread Jige Yu
Hi Java Experts, I sent this email incorrectly to loom-dev@ and was told on Reddit that core-libs-dev is the right list. The question is about the behavior of mapConcurrent() when the thread is interrupted. Currently mapConcurrent()'s finisher phase will re-interrupt the thread, then stop at wha

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-02-05 Thread Jige Yu
them. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* Jige Yu > *Sent:* Monday, 27 January 2025 17:00 > *To:* Viktor Klang > *Cc:* core-libs-dev@openjdk.org > *Subject

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-02-06 Thread Jige Yu
focusedId=14750017&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14750017 > > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* Viktor Klang > *Sent:* Thursday, 6 February 2025 11:51 >

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-02-05 Thread Jige Yu
t; This change is likely going to need some extra verbiage in the spec for > mapConcurrent, and thus a CSR. This behavior aligns mapConcurrent with how > parallel streams work in conjunction with interrup... > github.com > > > Cheers, > √ > > > *Viktor Klang* > Softw

Re: mapConcurrent() with InterruptedException

2025-01-26 Thread Jige Yu
for not preserving the encounter order, that would be a completely > different thing, and I'd encourage you to experiment with that if that > functionality would be interesting for your use-case(s). > > Again, thanks for your feedback! > > Cheers, > √ > > > *Viktor Kl

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-01-27 Thread Jige Yu
Hi! > > Please see: https://github.com/openjdk/jdk/pull/23100 > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* Jige Yu > *Sent:* Sunday, 26 January 2025 23:03 > *To:* Vik

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-05-25 Thread Jige Yu
pagation of interruption in CountedCompleters. > Adding support for such in (at least) GathererOp needs further study before > contemplating making any changes to mapConcurrent()'s interruption policy. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-05-26 Thread Jige Yu
t interrupt status is maintained, which is possible in this case. > > I have given it some more thought in the meantime, but I haven't arrived > in something more satisfactory than that, yet. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platfo

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-05-27 Thread Jige Yu
rentThread().interrupt(); throw new UncheckedInterruptedException(); } What are the concerns against such practice? On Mon, May 26, 2025 at 8:31 AM Jige Yu wrote: > Yeah, I think I missed the task cancellation and the joining part. > > When the mapConcurrent() thread is interrupted

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-05-28 Thread Jige Yu
heers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* Jige Yu > *Sent:* Wednesday, 28 May 2025 00:35 > *To:* Viktor Klang > *Cc:* core-libs-dev@openjdk.org > *Subject:* Re: [External] :

Re: Should mapConcurrent() respect time order instead of input order?

2025-06-02 Thread Jige Yu
Sorry. Forgot to copy to the mailing list. On Mon, Jun 2, 2025 at 7:27 AM Jige Yu wrote: > Thanks Viktor! > > I was thinking from my own experience that I wouldn't have automatically > assumed that a concurrent fanout library would by default preserve input > order. > >

Re: [External] : Re: Should mapConcurrent() respect time order instead of input order?

2025-06-02 Thread Jige Yu
ich adds to the complexity > of the implementation. Implementing an unordered version would likely look > different. > I'd definitely encourage taking the opportunity to attempt to implement it. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-06-02 Thread Jige Yu
cases. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* core-libs-dev on behalf of Jige > Yu > *Sent:* Friday, 30 May 2025 00:44 > *To:* David Holmes > *Cc:* core-libs-dev@openjdk.

Re: [External] : Re: Should mapConcurrent() respect time order instead of input order?

2025-06-02 Thread Jige Yu
race? > > The Gatherer doesn't know whether the Stream is unordered or ordered. The > operation should be semantically equivalent anyway. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- >

Should mapConcurrent() respect time order instead of input order?

2025-06-01 Thread Jige Yu
It seems like for most people, input order isn't that important for concurrent work, and concurrent results being in non-deterministic order is often expected. If mapConcurrent() just respect output encounter order: It'll be able to achieve *higher throughput* if an early task is slow, For exampl

Re: [External] : Re: Should mapConcurrent() respect time order instead of input order?

2025-06-04 Thread Jige Yu
gt; > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* Jige Yu > *Sent:* Monday, 2 June 2025 18:54 > *To:* Viktor Klang > *Cc:* core-libs-dev@openjdk.org > *Subject:* Re: [External] : Re: Should mapConcurre

Re: [External] : Re: Should mapConcurrent() respect time order instead of input order?

2025-06-04 Thread Jige Yu
gracefully by letting tasks run truly concurrently without an implicit ordering dependency. This reinforces my belief that an alternative gatherer, or a default behavior for mapConcurrent() that prioritizes concurrency (as the name mapConcurrent might suggest to many, akin to forEach), could be very

Re: [External] : Re: mapConcurrent() with InterruptedException

2025-05-29 Thread Jige Yu
ptions work fine too. I can't see harm being done for either case, compared to letting it keep running through all elements (what if the stream is infinite or very very long?) On Wed, May 28, 2025 at 10:19 PM David Holmes wrote: > On 29/05/2025 3:45 am, Jige Yu wrote: > > 17.2.

Re: [External] : Re: Should mapConcurrent() respect time order instead of input order?

2025-06-07 Thread Jige Yu
a/javase/24/docs/api/java.base/java/util/stream/Gatherers.html#mapConcurrent(int,java.util.function.Function) > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > -- > *From:* Jige Yu > *Sent:* Wednesday,

Re: Question about mapConcurrent() Behavior and Happens-Before Guarantees

2025-07-04 Thread Jige Yu
s interrupted. On Thu, Jul 3, 2025 at 10:29 AM David Alayachew wrote: > These questions necessitate runnable examples. Do you have any > > On Thu, Jul 3, 2025, 10:37 AM Jige Yu wrote: > >> Hi JDK Core Devs, >> >> I'm writing to you today with a

Question about mapConcurrent() Behavior and Happens-Before Guarantees

2025-07-03 Thread Jige Yu
Hi JDK Core Devs, I'm writing to you today with a question about the behavior of mapConcurrent() and its interaction with unchecked exceptions. I've been experimenting with the API and observed that mapConcurrent() blocks and joins all virtual threads upon an unchecked exception before propagating

Re: Question about mapConcurrent() Behavior and Happens-Before Guarantees

2025-07-07 Thread Jige Yu
e. Being a collector, it needs to first consume the input, similar to how most Collectors operate. So it might be a less intrusive path to ensure proper resource handling without altering usage patterns. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform G

Re: [External] : Re: Question about mapConcurrent() Behavior and Happens-Before Guarantees

2025-07-12 Thread Jige Yu
t; > Would you mind clariying *exactly* what you mean here—*what* happens-before > completion/exception? > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Group > Oracle > > -- > *From:* Jige Yu > *Sent:*

Re: Question about mapConcurrent() Behavior and Happens-Before Guarantees

2025-07-04 Thread Jige Yu
ats around happens-before enforcement and thread cancellation. Just my 2c, Cheers On Fri, Jul 4, 2025 at 8:55 AM Jige Yu wrote: > Yes. > > I got two tests that show the behavior difference between downstream > exception and upstream exception: > > > @Test public void map

Re: [External] : Re: Should mapConcurrent() respect time order instead of input order?

2025-06-30 Thread Jige Yu
he meantime, I want to reiterate that it is possible to build what > you're asking for, outside of the JDK. To gather experience, feedback, and > ultimately decide if the feature is worthwhile. > > Cheers, > √ > > > *Viktor Klang* > Software Architect, Java Platform Gr