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

Add support for virtual threads (Project Loom) #414

Closed
1 task done
onobc opened this issue Jun 10, 2023 · 5 comments
Closed
1 task done

Add support for virtual threads (Project Loom) #414

onobc opened this issue Jun 10, 2023 · 5 comments
Assignees
Milestone

Comments

@onobc
Copy link
Collaborator

onobc commented Jun 10, 2023

This is a Spring wide initiative for the end of the year and Spring Framework has spring-projects/spring-framework#23443 scheduled for the 6.1 release this fall.

  • [ ] Add support for Java 21 (TODO create issue)
  • [ ] Add config prop(s) for enabling virtual threads on listener container executors (default and concurrent)
  • Ensure proper use of synchronized (may not be issue as we only use on initial startup AFAICT)

ℹ️ The above will likely be turned into individual issues when we start looking into this.

See this PR that adds virtual thread support to Spring Framework for inspiration.

@onobc onobc assigned onobc and sobychacko and unassigned onobc Jun 20, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Jul 11, 2023

Add config prop(s) for enabling virtual threads on listener container executors (default and concurrent)

What did you have in mind here? A boolean flag to enable virtual threads or to allow an AsyncTaskExecutor to be set? FWIW, from what I've seen in other projects the latter is the much more common approach.

@sobychacko
Copy link
Collaborator

@wilkinsona We can go with the AsyncTaskExecutor if other projects are already doing it for virtual threads support. We are already using AsyncTaskExecutor for running the listener thread. What other projects are using it for VT support?

@wilkinsona
Copy link
Member

You can answer that with a code search.

Anywhere that's using a SimpleAsyncTaskExecutor (a new thread per task) is an excellent candidate for using a VirtualThreadTaskExecutor when the user's indicated that they want to use virtual threads.

@onobc onobc added this to the 1.0.0 milestone Jul 20, 2023
@onobc
Copy link
Collaborator Author

onobc commented Sep 23, 2023

Going w/ the AsyncTaskExecutor is much simpler than the config prop approach. The containers already support setting the executor. This really becomes an exercise of cleaning up any sync blocks. We will likely want to add a PulsarContainerPropertiesCustomizer in Boot though as the user currently has limited access to what they can configure on the container properties. I will create a code proposal under spring-projects/spring-boot#36347 for this.

onobc added a commit to onobc/spring-pulsar that referenced this issue Sep 23, 2023
See spring-projects#414

Use ReentrantLocks to avoid unnecessary virtual thread pinning.
onobc added a commit that referenced this issue Sep 23, 2023
See #414

Use ReentrantLocks to avoid unnecessary virtual thread pinning.
@onobc
Copy link
Collaborator Author

onobc commented Sep 27, 2023

Closing via 8c415e8

@onobc onobc closed this as completed Sep 27, 2023
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

No branches or pull requests

3 participants