Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview support for virtual threads #3871

Merged
merged 29 commits into from
Apr 27, 2023
Merged

Preview support for virtual threads #3871

merged 29 commits into from
Apr 27, 2023

Conversation

pditommaso
Copy link
Member

This PR implements a preliminary support for virtual threads

Signed-off-by: Paolo Di Tommaso <[email protected]>
@pditommaso pditommaso marked this pull request as draft April 14, 2023 18:02
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
validation/test.sh Outdated Show resolved Hide resolved
test-ci.sh Show resolved Hide resolved
test-ci.sh Show resolved Hide resolved
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
@pditommaso
Copy link
Member Author

pditommaso commented Apr 16, 2023

Doing some stress tests using this script that upload 300 files and download ~200 files.

Using platform (classic) thread it took ~ 9 mins

Completed at: 16-Apr-2023 10:50:15
Duration    : 8m 53s
CPU hours   : 0.3
Succeeded   : 581

Using virtual threads 7 min and 35 secs

Completed at: 16-Apr-2023 10:59:43
Duration    : 7m 35s
CPU hours   : (a few seconds)
Succeeded   : 581

Test script

process foo {
  publishDir "s3://nextflow-ci/outputs"
  input:
    val x
  output:
    path 'hello*'
  """
  head -c 50737410 </dev/urandom > hello${x}.txt
  """
}

process bar {
  input: 
    path x
  """
  head $x
  """
}

workflow {
  channel.of(1..300) | foo
  channel.fromPath('s3://nextflow-ci/uploads/*') | bar
}

nextflow-platform.log
nextflow-virtual.log

Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
@abhi18av
Copy link
Member

Hi Paolo 👋

Just curious about this improvement - going through the code it seems that it'll impact the file copy and task monitoring mechanism. However, for some reason when you mentioned about virtual threads last year, I thought it was in the context of replacing GPars library as it wasn't being frequently updated (ref https://github.com/GPars/GPars).

Did I misunderstand the overall intent then 🤔 ?

@pditommaso
Copy link
Member Author

Also GPars will benefit from virtual thread thanks this

https://github.com/nextflow-io/nextflow/pull/3871/files#diff-3f9b4052b1a59668dd036b9281994bde863cab86884c8677f967d75a1e6f37b5R33-R65

@abhi18av
Copy link
Member

Ah, I see now - so basically you're swapping the underlying primitives for the abstractions (DataFlow) in GPars library using the virtual threads!

@pditommaso
Copy link
Member Author

Yeah!

…rTest.groovy [ci skip]]

Signed-off-by: Paolo Di Tommaso <[email protected]>
@pditommaso pditommaso marked this pull request as ready for review April 27, 2023 18:43
@pditommaso pditommaso merged commit 5c42904 into master Apr 27, 2023
@pditommaso pditommaso deleted the virtual-threads branch April 27, 2023 18:48
abhi18av pushed a commit to abhi18av/nextflow that referenced this pull request Oct 28, 2023
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants