forked from nextflow-io/nextflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preview support for virtual threads (nextflow-io#3871)
This commit adds support for Java virtual threads. To enable this feature, the following variable should be declared in the launching environment: ``` export NXF_ENABLE_VIRTUAL_THREADS ``` Note, this feature it's required the use of Java 19 or later. Signed-off-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
ab725fc
commit 7fcdbc7
Showing
31 changed files
with
404 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,10 @@ | |
*/ | ||
|
||
package nextflow.util | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.Memoized | ||
import groovy.util.logging.Slf4j | ||
import groovyx.gpars.scheduler.Pool | ||
import groovyx.gpars.scheduler.ResizeablePool | ||
import groovyx.gpars.util.PoolFactory | ||
|
@@ -27,6 +29,7 @@ import groovyx.gpars.util.PoolFactory | |
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@Slf4j | ||
@CompileStatic | ||
class CustomPoolFactory implements PoolFactory { | ||
|
||
|
@@ -40,7 +43,8 @@ class CustomPoolFactory implements PoolFactory { | |
@Override | ||
synchronized Pool createPool() { | ||
|
||
def type = property(NXF_POOL_TYPE, 'default') | ||
final defType = Threads.useVirtual() ? 'virtual' : 'default' | ||
final type = property(NXF_POOL_TYPE, defType) | ||
switch (type) { | ||
case 'default': | ||
int poolSize = Runtime.runtime.availableProcessors() +1 | ||
|
@@ -66,6 +70,10 @@ class CustomPoolFactory implements PoolFactory { | |
int size = property(NXF_MAX_THREADS, cpus+1) as int | ||
return CustomThreadPool.unboundedPool(size) | ||
|
||
case 'virtual': | ||
log.debug "Creating virtual thread pool" | ||
return CustomThreadPool.virtualPool() | ||
|
||
default: | ||
throw new IllegalAccessException("Unknown thread pool type: `$type`") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.