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

Fixes #8007 - Support Loom. #8360

Merged
merged 4 commits into from
Aug 10, 2022
Merged

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Jul 31, 2022

Alternative implementation of support for virtual threads for HTTP/1.1, HTTP/2 and HTTP/3.

The virtual thread support is in AdaptiveExecutionStrategy.
When virtual threads are supported and enabled, reserved threads are disabled and
blocking tasks are run in a virtual thread instead that being executed by the Executor.

Signed-off-by: Simone Bordet [email protected]

Alternative implementation of support for virtual threads for HTTP/1.1, HTTP/2 and HTTP/3.

The virtual thread support is in AdaptiveExecutionStrategy.
When virtual threads are supported and enabled, reserved threads are disabled and
blocking tasks are run in a virtual thread instead that being executed by the Executor.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet requested review from gregw and lorban July 31, 2022 20:02
@sbordet
Copy link
Contributor Author

sbordet commented Jul 31, 2022

@gregw @lorban please review this alternative support for Loom, more in line with what suggested by @gregw.

It's not complete as we need to verify that all code paths that call application code are actually invoked with a virtual thread (so more testing needed), but it's functional enough to deserve a review to see if it is the right direction before doing more work.

@joakime
Copy link
Contributor

joakime commented Aug 2, 2022

Keep in mind that the prior Loom support PR #8035 still exists and is still open

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking much better.
I've made a couple of comments / niggles.

But I also don't like the way useVirtualThreads boolean is passed around.

Rather than configure connectors, I'm wondering if it could be a filed/attribute/property associated with the thread pool? The strategy could then look at the threadpool it has been given and work out how to act from that.

Now virtual thread configuration is done in ThreadPool implementation.
ReservedThreadExecutor heuristics has been changed to take into account virtual thread support, so that by default the number of reserved threads is 0 when using virtual threads.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet requested a review from gregw August 8, 2022 12:06
Signed-off-by: Simone Bordet <[email protected]>
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good.... but other than the niggles I've commented on, you also need to modify jetty-threadpool.xml and module to have a property for useVirtualThreads.

Or if you like, you could have a loom.mod that depended on thread pool and set the property.

Updated threadpool Jetty module and XML files.

Retrieving whether to use virtual threads from AdaptiveExecutionStrategy.doStart() to allow for late configuration of the thread pool.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet requested a review from gregw August 9, 2022 17:45
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than a specific test for the execution strategy would be good to have.

Comment on lines +474 to +477
if (isUseVirtualThreads())
VirtualThreads.startVirtualThread(task);
else
_executor.execute(task);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a test in AdaptiveExecutionStrategyTest for this. It should start a billion threads and be OK :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Billions are a thing of the past. I'll use trillions, because that's what's needed these days with 0.75 CPUs in the cloud.

Copy link
Contributor

@lorban lorban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sbordet sbordet merged commit be3d16b into jetty-10.0.x Aug 10, 2022
@sbordet sbordet deleted the jetty-10.0.x-8007-support-loom2 branch August 10, 2022 12:31
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.

4 participants