GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Sample JVM method exit via bytecode rewriting by fandreuz · Pull Request #1421 · async-profiler/async-profiler

Conversation

@fandreuz

@fandreuz fandreuz commented Jul 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

In this PR I enable recording JVM method exit via bytecode instrumentation. The bulk of this PR consists in:

  • tracking all exit points for the method
  • inserting invocation towards async-profiler functions
  • fixing jump offsets

I'm also adding a new parameter called latency.

  • When latency is absent, the previous behavior is kept
  • When latency is specified (can be 0) any execution of the method which exceeds latency is going to record a sample. total will contain the duration of the method execution.

Related issues

n/a

Motivation and context

There are several use cases enabled by this PR:

  • Recording the total duration of a method
  • Taking a sample only when the latency of a method exceeds a threshold

How has this been tested?

New tests in InstrumentTests.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
github-actions[bot]
github-actions Bot reviewed Jul 29, 2025
View reviewed changes

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/linkedList.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/linkedList.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/linkedList.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

github-actions[bot]
github-actions Bot reviewed Jul 29, 2025
View reviewed changes

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 5 commits July 29, 2025 16:37
@fandreuz
ops
2b6c8c8
@fandreuz
license
a126d33
@fandreuz
nn
4a7962e
@fandreuz
guard
69a69ad
@fandreuz
Merge branch 'master' into instrument-method-end
6509fd4
@fandreuz fandreuz changed the title Enable recording JVM method exit via bytecode instrumentation Sample JVM method exit via bytecode instrumentation Jul 29, 2025
fandreuz added 7 commits July 30, 2025 11:04
@fandreuz
comment
7048835
@fandreuz
todo
8109945
@fandreuz
wip
d6a4cc5
@fandreuz
ops
75491b6
@fandreuz
nn
3848e11
@fandreuz
revert
09daa29
@fandreuz
fix
f5fe93c
apangin
apangin reviewed Jul 31, 2025
View reviewed changes
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/opcode.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Jul 31, 2025
View reviewed changes
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Jul 31, 2025
View reviewed changes
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Jul 31, 2025
View reviewed changes
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 6 commits August 1, 2025 08:54
@fandreuz
nn
b344d40
@fandreuz
comments
76cc043
@fandreuz
cc
340b7bf
@fandreuz
more cc
e76a296
@fandreuz
all jumps
3546a96
@fandreuz
no on stack
d75e6cd
@fandreuz

fandreuz commented Aug 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

We're also missing tableswitch

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Aug 1, 2025
View reviewed changes
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 3 commits August 1, 2025 12:35
@fandreuz
cc
bff92d8
@fandreuz
cc
c511c25
@fandreuz
fix
e33f9be
@fandreuz
onlyjumps
579e2d6
@fandreuz
fandreuz force-pushed the instrument-method-end branch from bb14c68 to 579e2d6 Compare September 5, 2025 11:09
@fandreuz
relocation of base is same as its branches
2cbfe2a
@fandreuz
fandreuz force-pushed the instrument-method-end branch from 9a51a88 to 2cbfe2a Compare September 5, 2025 12:28
fandreuz added 5 commits September 5, 2025 12:29
@fandreuz
down
371439f
@fandreuz
linux only
99dc6b5
@fandreuz
jfr settings
b9769c7
@fandreuz
ops
058f7d0
@fandreuz
fail gracefully
65327e7
apangin
apangin reviewed Sep 5, 2025
View reviewed changes
Comment thread src/instrument.cpp Outdated
const char* class_name;
const char* method_name;
int out = rewriteClass(&class_name, &method_name);
if (out == 0) {

@apangin apangin Sep 5, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a case in switch below

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7f217a8

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I reverted this after 0f9931d, because this would cause some repetition where I handle errors

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 6 commits September 5, 2025 19:10
@fandreuz
switch and bad
7f217a8
@fandreuz
enum
47e1af6
@fandreuz
null terminated. member
0f9931d
@fandreuz
c_str
da0c740
@fandreuz
rewriteCodeForLatency only error
20cabce
@fandreuz
ops
dd32de0
apangin
apangin reviewed Sep 5, 2025
View reviewed changes
Comment thread src/instrument.cpp Outdated

constexpr u16 MAX_CODE_LENGTH = 65534;

enum {

@apangin apangin Sep 5, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it named enum and let functions return this type instead of int.
Constants no longer need to be negative.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bbcdd47

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/instrument.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz and others added 7 commits September 5, 2025 22:20
@fandreuz
nn
f79f1ce
@fandreuz
Constant
69cc699
@fandreuz
underscore
69d4fa2
@fandreuz
result
bbcdd47
@apangin
Minor edits
75784b9
@apangin
Minor edits
d900a34
@apangin
Minor edits
2b32d95
@apangin
apangin merged commit 2e0e3ab into async-profiler:master Sep 6, 2025
@fandreuz fandreuz mentioned this pull request Sep 10, 2025
Optimize method tracing when the function is not profiled #1471
Merged
@fandreuz fandreuz mentioned this pull request Sep 19, 2025
Latency Profiling enhancements #1499
Merged
@Baraa-Hasheesh Baraa-Hasheesh mentioned this pull request Oct 15, 2025
Fully use VM stack walker when selected & general enhancements for VM/VMX modes #1370
Closed
jbachorik pushed a commit to DataDog/async-profiler that referenced this pull request Jan 2, 2026
@fandreuz @jbachorik
Java method tracing + Latency profiling (async-profiler#1421)
9991863
jbachorik pushed a commit to DataDog/async-profiler that referenced this pull request Jan 6, 2026
@fandreuz @jbachorik
Java method tracing + Latency profiling (async-profiler#1421)
90075da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@apangin apangin apangin left review comments
@github-actions github-actions[bot] github-actions[bot] left review comments
+2 more reviewers
@Baraa-Hasheesh Baraa-Hasheesh Baraa-Hasheesh left review comments
@krk krk krk requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@fandreuz @Baraa-Hasheesh @apangin @krk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.