RFR: 8267209: Child threads should defer logging to after child-parent handshake

Thomas Stuefe stuefe at openjdk.java.net
Sun May 16 07:12:15 UTC 2021


Hi,

May I have reviews for this very simple change (triggered by this ML discussion [1]):

On Linux and BSD, we have a handshake between creator thread and newborn thread. Creator thread waits until the newborn is alive and reports back via a monitor handshake.

The newborn should avoid doing anything unnecessary before reporting back to the creator. But we added logging there, whose performance impact can be anything. We should defer logging to after that handshake.

I ran OPs [1] test on my machine and with logging to a very fast ssd enabled:


thomas at starfish:/shared/projects/openjdk$ ./jdk-jdk/output-release/images-stock/jdk/bin/java -Xlog:os+thread:t1.log -cp ./test/repros/repros8/target/repros8-1.0.jar de.stuefe.repros.WaishonTest
Duration: 5191


with this patch test time drops by about 19%:


thomas at starfish:/shared/projects/openjdk$ ./jdk-jdk/output-release/images-stock/jdk/bin/java -Xlog:os+thread:t1.log -cp ./test/repros/repros8/target/repros8-1.0.jar de.stuefe.repros.WaishonTest
Duration: 4228


No perceptible difference with logging disabled, as it should be.

---

(Side note: We don't do this handshake on AIX and Windows. Instead, there, we create the thread in suspended state and resume it later. Would be nice to get rid of that handshake for Linux too.)

[1] https://mail.openjdk.java.net/pipermail/discuss/2021-May/005807.html

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

Commit messages:
 - start

Changes: https://git.openjdk.java.net/jdk/pull/4042/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4042&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8267209
  Stats: 12 lines in 2 files changed: 6 ins; 6 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4042.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4042/head:pull/4042

PR: https://git.openjdk.java.net/jdk/pull/4042


More information about the hotspot-runtime-dev mailing list