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

Replace synchronized blocks with reentrant locks #702

Closed
mrotteveel opened this issue Sep 11, 2022 · 2 comments
Closed

Replace synchronized blocks with reentrant locks #702

mrotteveel opened this issue Sep 11, 2022 · 2 comments

Comments

@mrotteveel
Copy link
Member

Jaybird currently uses a lot of synchronized blocks for thread-safety. Java 19 introduces virtual threads with Project Loom (as a preview feature). Virtual threads and synchronized blocks currently don't work well together (or more correctly, seriously reduce the benefits/usability of virtual threads due to thread pinning). See https://openjdk.org/jeps/425 for details. Although JEP 425 says "In a future release, we may be able to remove the first limitation above (pinning inside synchronized).", this is not a solved problem, and may never surface (see https://mail.openjdk.org/pipermail/jdk-dev/2022-June/006721.html).

As a result, replacing synchronized blocks with reentrant locks (and maybe at the same time, look at reducing use of locks) makes sense to allow Jaybird to make use of virtual thread without pinning (that is, for the pure-java protocol, as calling native methods will still cause pinning).

@mrotteveel
Copy link
Member Author

Still needs a review of other uses of synchronized.

@mrotteveel
Copy link
Member Author

Remaining synchronized uses are OK, and can remain in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant