From dl at cs.oswego.edu Fri Feb 21 15:18:46 2025 From: dl at cs.oswego.edu (Doug Lea) Date: Fri, 21 Feb 2025 10:18:46 -0500 Subject: Improved delayed task handling Message-ID: <251f6609-5c00-410d-96f9-fe7a776f7088@cs.oswego.edu> Hi all, We're in the process of improving delayed task handling, mainly by adding a specialized lazily-constructed ScheduledExecutorService to ForkJoinPool. This will be used internally in Loom and CompletableFutures, but will also be available more generally. Details are in the openjdk PR at https://github.com/openjdk/jdk/pull/23702. Comments would be welcome -- at github before committing, on lists otherwise. -Doug From george.lu at broadcom.com Fri Feb 28 20:51:00 2025 From: george.lu at broadcom.com (George Lu) Date: Fri, 28 Feb 2025 12:51:00 -0800 Subject: ForkJoinPool TC underflow issue in JDK 11 and 17 (JDK-8330017) Message-ID: Hi all, There is a known issue (JDK-8330017) in JDK 11 and 17 where the ForkJoinPool can hang when the Release Count (RC) reaches ForkJoinPool.MAX_CAP. This occurs due to an underflow in Total Count (TC) when attempting to signal for deregisterWorker. Specifically, in JDK 17, the following line: compareAndSetCtl(c, ((UC_MASK & (c - TC_UNIT)) | (prevCtl & SP_MASK)))) When TC == 0, (c - TC_UNIT) underflows, unintentionally decrementing RC by 1. Notably, TC == 0 is not a rare edge case (since total workers == parallelism is common), meaning this accidental underflow can occur frequently. We have encountered this issue in two of our long-running JVMs. A possible fix is to properly mask TC and RC as follows: compareAndSetCtl(c, ((RC_MASK & c) | (TC_MASK & (c - TC_UNIT)) | (prevCtl & SP_MASK)))) Regards, George -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.