jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8295851: Do not use ttyLock in BytecodeTracer::trace

Open coleenp opened this issue 5 months ago • 7 comments
trafficstars

This didn't need ttyLock for synchronization, the code only needs to see if the method changes so it can print the method name before the bytecodes, like:

[490166] static void java.lang.String.() [490166] 13 18 putstatic 613 <java/lang/String.CASE_INSENSITIVE_ORDER:Ljava/util/Comparator;> [490166] 14 21 return

[490166] static void java.lang.System.() [490166] 15 0 invokestatic 471 <java/lang/System.registerNatives()V> [490166] 16 3 aconst_null [490166] 17 4 putstatic 474 <java/lang/System.in:Ljava/io/InputStream;>

Verified manually and added some parallelism to the test, and fixed trace() to initialize is_linked(), which it always is. Also ran tier1-4.


Progress

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-8295851: Do not use ttyLock in BytecodeTracer::trace (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25915/head:pull/25915
$ git checkout pull/25915

Update a local copy of the PR:
$ git checkout pull/25915
$ git pull https://git.openjdk.org/jdk.git pull/25915/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25915

View PR using the GUI difftool:
$ git pr show -t 25915

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25915.diff

Using Webrev

Link to Webrev Comment

coleenp avatar Jun 20 '25 11:06 coleenp

:wave: Welcome back coleenp! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Jun 20 '25 11:06 bridgekeeper[bot]

@coleenp This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8295851: Do not use ttyLock in BytecodeTracer::trace

Reviewed-by: dholmes, matsaave

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 121 new commits pushed to the master branch:

  • 12196baf6700d00c244747cfa22767e532a4a963: 8358624: ImmutableDescriptor violates equals/hashCode contract after deserialization
  • a471fe992fc0d71ba65b5fdbcc44b97a2783b90a: 8360539: DTLS handshakes fails due to improper cookie validation logic
  • 839cede1a46b05d27abeaffbbd82c241910035cd: 8357289: Break down the String constructor into smaller methods
  • ... and 118 more: https://git.openjdk.org/jdk/compare/49a82d880636a632f4a3471b14b1b1b29ce1d5e6...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

openjdk[bot] avatar Jun 20 '25 11:06 openjdk[bot]

@coleenp The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

openjdk[bot] avatar Jun 20 '25 11:06 openjdk[bot]

Webrevs

mlbridge[bot] avatar Jun 20 '25 11:06 mlbridge[bot]

You could use a ThreadLocal for the current method being printed.

Oh yes that would be better, but I hate to add things to Thread for just one use. Actually, reprinting the method name probably helps with readability if multiple threads are interleaving output.

Thanks for the review @dholmes-ora

coleenp avatar Jun 25 '25 21:06 coleenp

You could use a ThreadLocal for the current method being printed.

Oh yes that would be better, but I hate to add things to Thread for just one use.

No I literally meant a THREAD_LOCAL ie.

static THREAD_LOCAL Method* _method_currently_being_printed = nullptr;

dholmes-ora avatar Jun 27 '25 04:06 dholmes-ora

Oh yes, we don't use THREAD_LOCAL that much. I still think we want to repeat the method name if the threads become interweaved.

coleenp avatar Jun 27 '25 11:06 coleenp

Should the test also include the simple serial version?

Since we don't really verify the output, I don't think one would be needed. The test was originally added when there was a safepointing lock around BytecodeTracer in JDK 7 and the Method* moved, so all the test did was verify that tracing bytecodes didn't crash. With the concurrency I added, it did crash and found a bug that I fixed in BytecodeTracer::trace function.

coleenp avatar Jun 27 '25 15:06 coleenp

Thanks Matias and David for reviewing. /integrate

coleenp avatar Jun 27 '25 16:06 coleenp

Going to push as commit 4edf791aecd432ecde00652acfaabddf136f4ca7. Since your change was applied there have been 121 commits pushed to the master branch:

  • 12196baf6700d00c244747cfa22767e532a4a963: 8358624: ImmutableDescriptor violates equals/hashCode contract after deserialization
  • a471fe992fc0d71ba65b5fdbcc44b97a2783b90a: 8360539: DTLS handshakes fails due to improper cookie validation logic
  • 839cede1a46b05d27abeaffbbd82c241910035cd: 8357289: Break down the String constructor into smaller methods
  • ... and 118 more: https://git.openjdk.org/jdk/compare/49a82d880636a632f4a3471b14b1b1b29ce1d5e6...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Jun 27 '25 16:06 openjdk[bot]

@coleenp Pushed as commit 4edf791aecd432ecde00652acfaabddf136f4ca7.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar Jun 27 '25 16:06 openjdk[bot]