apache / pekko

Build highly concurrent, distributed, and resilient message-driven applications using Java/Scala
https://pekko.apache.org/
Apache License 2.0
1.17k stars 139 forks source link

feat: Add virtual thread support #1299

Closed He-Pin closed 3 weeks ago

He-Pin commented 4 months ago

Motivation: Add virtual thread support

Modification:

  1. Run Actor on top of ThreadPerTaskExecutor.

Result: Virtual thread support was added.

Note: As Mailbox extends on ForkJoinTask and when we run on ThreadPerTaskExecutor, it's pointless.

pjfanning commented 4 months ago

This is probably useful but I would appreciate if we don't merge it until after 1.1.0-M1 is released. I think there are some changes that we need in the implementation and we have to work out how to test it.

I don't think this dispatcher should be the default, even if you use JDK 21+. Users should only be able to opt in to using it.

Dispatchers are pluggable so users can create their own dispatcher for this while they are waiting for us to release one.

He-Pin commented 4 months ago

Yes, I would like to make it in 1.1.0 M2 or M3 , Need more time to polish it.

He-Pin commented 1 month ago

@pjfanning @alexandru @Roiocam @alexandru What do you think about the current way to support virtual thread in pekko? I was want to replace the virtual thread's shceudler, but that need a methodHandler method in Java 9+.

pjfanning commented 1 month ago

Could you add a basic unit test?

pjfanning commented 1 month ago

@He-Pin would you have time to add a test that runs when we build with java 21+? And there is my comment about using MethodHandles publicLookup instead of lookup. Generally, I support adding this. I'm hoping to try to get the final changes merged so that we can press ahead with Pekko 1.1.0 or 1.1.0-M2 release.

He-Pin commented 1 month ago

I'm a little busy at work but I would like to address this this weekend night, at day I need go to the apache coc in HangZhou.

pjfanning commented 3 weeks ago

1436 was merged