RFR: 8296896: Change virtual Thread.yield to use external submit [v2]

Alan Bateman alanb at openjdk.org
Thu Dec 8 07:21:13 UTC 2022


> The implementation of Thread.yield for virtual threads is currently a "lazy submit". This means the task for the virtual thread is queued to the carrier/worker local queue without signalling other threads. This behavior can be surprising/unfair when there are tasks in the submission queues, say when a platform thread has started or unparked a virtual thread.
> 
> Ron, Doug Lea, Viktor Klang and I have discussed this topic and propose to change Thread.yield to  use "external submit" when the local task queue is empty, and to push to the local queue when not empty. The change improves the fairness but will of course increase the chances that repeated Thread.yield will bounce between carriers.

Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:

 - Merge
 - Fix typo in test comment
 - Reduce instanceof checks
 - Update
 - Initial commit

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/11533/files
  - new: https://git.openjdk.org/jdk/pull/11533/files/2e707757..151cbd0d

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=11533&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=11533&range=00-01

  Stats: 12718 lines in 291 files changed: 8666 ins; 2982 del; 1070 mod
  Patch: https://git.openjdk.org/jdk/pull/11533.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11533/head:pull/11533

PR: https://git.openjdk.org/jdk/pull/11533


More information about the core-libs-dev mailing list