You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by tison <wa...@gmail.com> on 2023/11/07 13:16:39 UTC

[OT] Evaluate Virtual thread [WAS][DISCUSS] Moving to Java 21

Hi,

I check the docs for Virtual Threads[1][2][3]. It comes up to me with two
major concerns about its real-world improvement for Pulsar's scenario:

1. All of the virtual threads share the same schedule pool, which means
that all tasks run on virtual threads competing with each other. It can be
better to separate different logical concurrent groups into dedicated
groups, although Goroutines share the same global scheduler also.

2. The point where the virtual thread "yield" ("unmount" in the documents)
is not quite clear. It's written to be "usually Blocking IO" but can be
also Future::get or others. It's not easy to audit the change.

Best,
tison.

[1] https://openjdk.org/jeps/444
[2]
https://blogs.oracle.com/javamagazine/post/going-inside-javas-project-loom-and-virtual-threads
[3] https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html


Lari Hotari <lh...@apache.org> 于2023年10月21日周六 13:22写道:

> Thanks for suggesting. That's a good way to prevent regressions. I made
> the changes to schedule a daily build with JDK 21. Please review
> https://github.com/apache/pulsar/pull/21410
>
> -Lari
>
> On 2023/10/20 12:22:44 Christophe Bornet wrote:
> > Nice.
> > Would it be possible to have a daily build on JDK 21 to ensure it runs
> > properly ?
> >
> > Le ven. 20 oct. 2023 à 00:34, Lari Hotari <lh...@apache.org> a écrit :
> > >
> > > Hi all,
> > >
> > > I can now confirm that apache/pulsar master branch compiles and runs
> all tests in Pulsar CI successfully with Java 21. Therefore, we have
> already accomplished the first level of Java 21 support.
> > >
> > > Example of Pulsar CI build with Java 21:
> > > https://github.com/lhotari/pulsar/actions/runs/6577911040
> > >
> > > This experiment was run with PR #21400 changes which adds an option in
> manually triggered GitHub Actions based Pulsar CI builds with Java 21
> selected as the runtime for the build and test runtime and also as the Java
> runtime for docker images/containers used in integration & system tests
> which are part of the Pulsar CI build.
> > >
> > > Please review the PR https://github.com/apache/pulsar/pull/21400,
> let's get it merged.
> > > By default, Java 17 will be used, so it should be ok to merge this to
> master branch without any separate decisions such as PIPs.
> > >
> > > -Lari
> > >
> > > On 2023/10/19 12:23:03 Lari Hotari wrote:
> > > > I have created https://github.com/apache/pulsar/pull/21400 which
> parameterizes the JDK version used for the Pulsar CI GitHub Actions
> workflow. When triggering the workflow
> > > > manually, it's possible to choose between JDK 17 and JDK 21 from a
> dropdown menu.
> > > > The PR contains more details, please review. Once we have this
> merged, it will be easy to experiment with Java 21 when needed.
> > > >
> > > > -Lari
> > > >
> > > > On 2023/10/19 03:06:39 tison wrote:
> > > > > > I think Java 21 can open the door for Virtual Threads[1].
> > > > >
> > > > > Yep. This should be a good motivation for using JDK 21.
> > > > >
> > > > > We may start a survey in the community a few months later for JDK
> 21
> > > > > feedback (as we /will/ switch the runtime to JDK 21 in Docker) and
> try to
> > > > > switch the toolkit.
> > > > >
> > > > > Best,
> > > > > tison.
> > > > >
> > > > >
> > > > > Zixuan Liu <no...@gmail.com> 于2023年10月19日周四 10:56写道:
> > > > >
> > > > > > +1 for compatibility with Java 21.
> > > > > >
> > > > > > Next step: Migrating the Pulsar Server runtime to Java 21 from
> Java 17
> > > > > > in the Docker image and CI. Pulsar Client/Admin continues to use
> Java
> > > > > > 8.
> > > > > >
> > > > > > Thanks,
> > > > > > Zixuan
> > > > > >
> > > > > > Lari Hotari <lh...@apache.org> 于2023年10月18日周三 06:02写道:
> > > > > > >
> > > > > > > Dear Pulsar community,
> > > > > > >
> > > > > > > Java 21 was released on September 19th and has now become the
> current
> > > > > > Java LTS release.
> > > > > > >
> > > > > > > I've begun preparations in the Pulsar code base to allow for
> Java 21 to
> > > > > > be used as the development runtime for compiling the code and
> running tests
> > > > > > in the master branch. This is a proactive measure to gear up for
> Java 21
> > > > > > without committing to the switch just yet. It will help us
> understand the
> > > > > > necessary changes when we are able to compile the code and run
> all tests
> > > > > > with Java 21.
> > > > > > >
> > > > > > > For instance, I initiated the process with the following PRs:
> > > > > > > - Upgrade Mockito to 5.6.0 to support Java 21 [1]
> > > > > > > - Upgrade Gradle Enterprise Maven Extension to support Java 21
> [2]
> > > > > > > After these are merged, it should be possible to start running
> tests
> > > > > > with Java 21 to see what is possibly broken and continue
> iterating.
> > > > > > > Moreover, the upgrade to Lombok 1.18.30 for Java 21 support
> has already
> > > > > > been merged [3].
> > > > > > >
> > > > > > > Java 17 has been the recommended runtime for Pulsar server
> components
> > > > > > since the Pulsar 2.11 release [4]. Meanwhile, the Pulsar client
> continues
> > > > > > to be supported on Java 8+.
> > > > > > >
> > > > > > > I would like to initiate discussions about making Java 21 the
> > > > > > recommended and default runtime for Pulsar server components.
> Note that
> > > > > > there will be no change to the Pulsar client, which will remain
> on Java 8+.
> > > > > > >
> > > > > > > I guess we could come up with a PIP to document the decision
> once we
> > > > > > have had this discussion.
> > > > > > >
> > > > > > > Do you think we can target the switch from Java 17 to Java 21
> for the
> > > > > > Pulsar 3.2 release?
> > > > > > > Could anyone update me on the current schedule for Pulsar 3.2?
> > > > > > >
> > > > > > > -Lari
> > > > > > >
> > > > > > > [1] - https://github.com/apache/pulsar/pull/21385
> > > > > > > [2] - https://github.com/apache/pulsar/pull/21384
> > > > > > > [3] - https://github.com/apache/pulsar/pull/21278
> > > > > > > [4] -
> > > > > >
> https://github.com/apache/pulsar#pulsar-runtime-java-version-recommendation
> > > > > >
> > > > >
> > > >
> >
>

Re: [OT] Evaluate Virtual thread [WAS][DISCUSS] Moving to Java 21

Posted by 太上玄元道君 <da...@apache.org>.
In the past, threads usually blocked on LockUtil.park(…), and AQS is
depends on it to park threads.

Virtual thread only solved thread blocking on JDK layer by rewriting
LockUtik.park(…)

In some conditions, the carrier thread will be blocked (I only remember the
following points)
1. JNI calling
2. synchronized
3. system calling

tison <wa...@gmail.com>于2023年11月7日 周二21:19写道:

> Hi,
>
> I check the docs for Virtual Threads[1][2][3]. It comes up to me with two
> major concerns about its real-world improvement for Pulsar's scenario:
>
> 1. All of the virtual threads share the same schedule pool, which means
> that all tasks run on virtual threads competing with each other. It can be
> better to separate different logical concurrent groups into dedicated
> groups, although Goroutines share the same global scheduler also.
>
> 2. The point where the virtual thread "yield" ("unmount" in the documents)
> is not quite clear. It's written to be "usually Blocking IO" but can be
> also Future::get or others. It's not easy to audit the change.
>
> Best,
> tison.
>
> [1] https://openjdk.org/jeps/444
> [2]
>
> https://blogs.oracle.com/javamagazine/post/going-inside-javas-project-loom-and-virtual-threads
> [3] https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html
>
>
> Lari Hotari <lh...@apache.org> 于2023年10月21日周六 13:22写道:
>
> > Thanks for suggesting. That's a good way to prevent regressions. I made
> > the changes to schedule a daily build with JDK 21. Please review
> > https://github.com/apache/pulsar/pull/21410
> >
> > -Lari
> >
> > On 2023/10/20 12:22:44 Christophe Bornet wrote:
> > > Nice.
> > > Would it be possible to have a daily build on JDK 21 to ensure it runs
> > > properly ?
> > >
> > > Le ven. 20 oct. 2023 à 00:34, Lari Hotari <lh...@apache.org> a
> écrit :
> > > >
> > > > Hi all,
> > > >
> > > > I can now confirm that apache/pulsar master branch compiles and runs
> > all tests in Pulsar CI successfully with Java 21. Therefore, we have
> > already accomplished the first level of Java 21 support.
> > > >
> > > > Example of Pulsar CI build with Java 21:
> > > > https://github.com/lhotari/pulsar/actions/runs/6577911040
> > > >
> > > > This experiment was run with PR #21400 changes which adds an option
> in
> > manually triggered GitHub Actions based Pulsar CI builds with Java 21
> > selected as the runtime for the build and test runtime and also as the
> Java
> > runtime for docker images/containers used in integration & system tests
> > which are part of the Pulsar CI build.
> > > >
> > > > Please review the PR https://github.com/apache/pulsar/pull/21400,
> > let's get it merged.
> > > > By default, Java 17 will be used, so it should be ok to merge this to
> > master branch without any separate decisions such as PIPs.
> > > >
> > > > -Lari
> > > >
> > > > On 2023/10/19 12:23:03 Lari Hotari wrote:
> > > > > I have created https://github.com/apache/pulsar/pull/21400 which
> > parameterizes the JDK version used for the Pulsar CI GitHub Actions
> > workflow. When triggering the workflow
> > > > > manually, it's possible to choose between JDK 17 and JDK 21 from a
> > dropdown menu.
> > > > > The PR contains more details, please review. Once we have this
> > merged, it will be easy to experiment with Java 21 when needed.
> > > > >
> > > > > -Lari
> > > > >
> > > > > On 2023/10/19 03:06:39 tison wrote:
> > > > > > > I think Java 21 can open the door for Virtual Threads[1].
> > > > > >
> > > > > > Yep. This should be a good motivation for using JDK 21.
> > > > > >
> > > > > > We may start a survey in the community a few months later for JDK
> > 21
> > > > > > feedback (as we /will/ switch the runtime to JDK 21 in Docker)
> and
> > try to
> > > > > > switch the toolkit.
> > > > > >
> > > > > > Best,
> > > > > > tison.
> > > > > >
> > > > > >
> > > > > > Zixuan Liu <no...@gmail.com> 于2023年10月19日周四 10:56写道:
> > > > > >
> > > > > > > +1 for compatibility with Java 21.
> > > > > > >
> > > > > > > Next step: Migrating the Pulsar Server runtime to Java 21 from
> > Java 17
> > > > > > > in the Docker image and CI. Pulsar Client/Admin continues to
> use
> > Java
> > > > > > > 8.
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Zixuan
> > > > > > >
> > > > > > > Lari Hotari <lh...@apache.org> 于2023年10月18日周三 06:02写道:
> > > > > > > >
> > > > > > > > Dear Pulsar community,
> > > > > > > >
> > > > > > > > Java 21 was released on September 19th and has now become the
> > current
> > > > > > > Java LTS release.
> > > > > > > >
> > > > > > > > I've begun preparations in the Pulsar code base to allow for
> > Java 21 to
> > > > > > > be used as the development runtime for compiling the code and
> > running tests
> > > > > > > in the master branch. This is a proactive measure to gear up
> for
> > Java 21
> > > > > > > without committing to the switch just yet. It will help us
> > understand the
> > > > > > > necessary changes when we are able to compile the code and run
> > all tests
> > > > > > > with Java 21.
> > > > > > > >
> > > > > > > > For instance, I initiated the process with the following PRs:
> > > > > > > > - Upgrade Mockito to 5.6.0 to support Java 21 [1]
> > > > > > > > - Upgrade Gradle Enterprise Maven Extension to support Java
> 21
> > [2]
> > > > > > > > After these are merged, it should be possible to start
> running
> > tests
> > > > > > > with Java 21 to see what is possibly broken and continue
> > iterating.
> > > > > > > > Moreover, the upgrade to Lombok 1.18.30 for Java 21 support
> > has already
> > > > > > > been merged [3].
> > > > > > > >
> > > > > > > > Java 17 has been the recommended runtime for Pulsar server
> > components
> > > > > > > since the Pulsar 2.11 release [4]. Meanwhile, the Pulsar client
> > continues
> > > > > > > to be supported on Java 8+.
> > > > > > > >
> > > > > > > > I would like to initiate discussions about making Java 21 the
> > > > > > > recommended and default runtime for Pulsar server components.
> > Note that
> > > > > > > there will be no change to the Pulsar client, which will remain
> > on Java 8+.
> > > > > > > >
> > > > > > > > I guess we could come up with a PIP to document the decision
> > once we
> > > > > > > have had this discussion.
> > > > > > > >
> > > > > > > > Do you think we can target the switch from Java 17 to Java 21
> > for the
> > > > > > > Pulsar 3.2 release?
> > > > > > > > Could anyone update me on the current schedule for Pulsar
> 3.2?
> > > > > > > >
> > > > > > > > -Lari
> > > > > > > >
> > > > > > > > [1] - https://github.com/apache/pulsar/pull/21385
> > > > > > > > [2] - https://github.com/apache/pulsar/pull/21384
> > > > > > > > [3] - https://github.com/apache/pulsar/pull/21278
> > > > > > > > [4] -
> > > > > > >
> >
> https://github.com/apache/pulsar#pulsar-runtime-java-version-recommendation
> > > > > > >
> > > > > >
> > > > >
> > >
> >
>