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

Sample JVM method exit via bytecode rewriting #1421

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.

Sign up for GitHub

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

Merged
apangin merged 273 commits into async-profiler:master from fandreuz:instrument-method-end
Sep 6, 2025

Uh oh!

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

Merged

Sample JVM method exit via bytecode rewriting #1421

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
273 commits
Select commit Hold shift + click to select a range
2b6c8c8
ops
fandreuz Jul 29, 2025
a126d33
license
fandreuz Jul 29, 2025
4a7962e
nn
fandreuz Jul 29, 2025
69a69ad
guard
fandreuz Jul 29, 2025
6509fd4
Merge branch 'master' into instrument-method-end
fandreuz Jul 29, 2025
7048835
comment
fandreuz Jul 30, 2025
8109945
todo
fandreuz Jul 30, 2025
d6a4cc5
wip
fandreuz Jul 31, 2025
75491b6
ops
fandreuz Jul 31, 2025
3848e11
nn
fandreuz Jul 31, 2025
09daa29
revert
fandreuz Jul 31, 2025
f5fe93c
fix
fandreuz Jul 31, 2025
b344d40
nn
fandreuz Aug 1, 2025
76cc043
comments
fandreuz Aug 1, 2025
340b7bf
cc
fandreuz Aug 1, 2025
e76a296
more cc
fandreuz Aug 1, 2025
3546a96
all jumps
fandreuz Aug 1, 2025
d75e6cd
no on stack
fandreuz Aug 1, 2025
bff92d8
cc
fandreuz Aug 1, 2025
c511c25
cc
fandreuz Aug 1, 2025
e33f9be
fix
fandreuz Aug 1, 2025
c54d449
fix stackmap offsets
fandreuz Aug 1, 2025
7ee7963
cc
fandreuz Aug 1, 2025
a0a51bc
better
fandreuz Aug 1, 2025
093b480
dont skip new invokestatic
fandreuz Aug 1, 2025
0dafc13
rename fnc
fandreuz Aug 1, 2025
915252c
Merge branch 'master' into instrument-method-end
fandreuz Aug 5, 2025
f9386a3
no throw
fandreuz Aug 5, 2025
cb2d7de
check size
fandreuz Aug 5, 2025
7fed29e
not strict
fandreuz Aug 5, 2025
a246915
move down
fandreuz Aug 5, 2025
e48f082
put back record start
fandreuz Aug 5, 2025
3bd0c66
cc
fandreuz Aug 5, 2025
0a329de
missing rel_tab
fandreuz Aug 5, 2025
42c99ce
cc
fandreuz Aug 5, 2025
113077b
jump party
fandreuz Aug 5, 2025
18dfad0
tableswitch
fandreuz Aug 5, 2025
11f1f9a
lookupswitch
fandreuz Aug 5, 2025
c5f9822
align
fandreuz Aug 5, 2025
cd2f8a7
arg latency
fandreuz Aug 5, 2025
017ea26
pick up latency
fandreuz Aug 5, 2025
6fbfc67
use latency in br
fandreuz Aug 5, 2025
17b62e0
fix type
fandreuz Aug 5, 2025
d4347bf
some fixes
fandreuz Aug 5, 2025
feeaefa
move include
fandreuz Aug 5, 2025
503f042
entry/exit
fandreuz Aug 5, 2025
de7f9e5
mv down
fandreuz Aug 5, 2025
d544509
ops
fandreuz Aug 5, 2025
1165dc3
fixes
fandreuz Aug 5, 2025
e5a1de6
cc
fandreuz Aug 5, 2025
cb9f331
latency stuff
fandreuz Aug 6, 2025
27b2ca4
ops
fandreuz Aug 6, 2025
1310a71
tl
fandreuz Aug 6, 2025
e5fdc01
test
fandreuz Aug 6, 2025
5f15bdd
op[s
fandreuz Aug 6, 2025
c86f26f
fix test name
fandreuz Aug 6, 2025
2a8dac1
fix test
fandreuz Aug 6, 2025
71f0ac3
fix test
fandreuz Aug 6, 2025
d7d261d
nn
fandreuz Aug 6, 2025
9d9f19b
record duration
fandreuz Aug 6, 2025
0295072
record duration test
fandreuz Aug 6, 2025
1788512
Revert "record duration"
fandreuz Aug 6, 2025
44c657e
indent
fandreuz Aug 6, 2025
c8e302f
backwards
fandreuz Aug 6, 2025
4f65563
license
fandreuz Aug 6, 2025
01254fc
Merge branch 'master' into instrument-method-end
fandreuz Aug 7, 2025
269b220
latency can be zero
fandreuz Aug 7, 2025
e406fe6
fix stack map
fandreuz Aug 7, 2025
8f12f02
ops
fandreuz Aug 7, 2025
03f4246
rename var
fandreuz Aug 7, 2025
f0577de
fix test
fandreuz Aug 7, 2025
fa4c880
ops
fandreuz Aug 7, 2025
876a689
check zero
fandreuz Aug 7, 2025
045632b
fix exception table
fandreuz Aug 8, 2025
f54abca
fix stackmap offset resizing
fandreuz Aug 8, 2025
2990c4b
no need to make narrow jump wider
fandreuz Aug 8, 2025
8676b69
tidy
fandreuz Aug 8, 2025
ab279a2
handle wide opcode
fandreuz Aug 8, 2025
0159b9c
ls and ts
fandreuz Aug 8, 2025
021388d
ops
fandreuz Aug 8, 2025
43829bd
nn
fandreuz Aug 11, 2025
f4b9298
nn
fandreuz Aug 11, 2025
d097225
wip
fandreuz Aug 11, 2025
0ca3d6d
wp
fandreuz Aug 13, 2025
bdfe5f1
ops
fandreuz Aug 13, 2025
0a0f7a7
it works
fandreuz Aug 13, 2025
1a83308
nop
fandreuz Aug 13, 2025
9b6e710
nn
fandreuz Aug 13, 2025
d03ad26
tests
fandreuz Aug 13, 2025
2d381ab
fix and test
fandreuz Aug 13, 2025
bd80ab2
test name
fandreuz Aug 13, 2025
302e621
recursive test
fandreuz Aug 13, 2025
0151adf
rm prints
fandreuz Aug 13, 2025
0ef213b
logs
fandreuz Aug 13, 2025
e3eeebe
start time
fandreuz Aug 13, 2025
9a365ad
fix macos
fandreuz Aug 13, 2025
3ecc4aa
instrument all
fandreuz Aug 14, 2025
41f9ced
init
fandreuz Aug 14, 2025
27db95b
new test
fandreuz Aug 14, 2025
d9119b2
Merge branch 'instrument-all' into instrument-method-end
fandreuz Aug 14, 2025
758c7b4
fix bugs. new test
fandreuz Aug 14, 2025
7192f7c
review
fandreuz Aug 14, 2025
383d3f3
Merge branch 'instrument-all' into instrument-method-end
fandreuz Aug 14, 2025
feebd2c
ops
fandreuz Aug 14, 2025
6e104fa
Merge branch 'master' into instrument-method-end
fandreuz Aug 14, 2025
a64d643
tmp
fandreuz Aug 14, 2025
ffdf98c
fixes
fandreuz Aug 14, 2025
763bab9
fix loc table index
fandreuz Aug 15, 2025
d8a48a4
fix conflict
fandreuz Aug 15, 2025
d80969c
fix full_frame
fandreuz Aug 15, 2025
9aa860b
verify all
fandreuz Aug 15, 2025
5ab2730
error
fandreuz Aug 15, 2025
9873940
nn
fandreuz Aug 15, 2025
96dc49d
fix
fandreuz Aug 15, 2025
f616b28
iinc
fandreuz Aug 15, 2025
8794563
bugfix
fandreuz Aug 15, 2025
6be8e25
stuff
fandreuz Aug 15, 2025
8de432a
ops
fandreuz Aug 15, 2025
db3e21d
nn
fandreuz Aug 17, 2025
74655c6
memset
fandreuz Aug 17, 2025
4e051d3
can be unsigned
fandreuz Aug 18, 2025
5372ebe
constants
fandreuz Aug 18, 2025
3952f4a
fix op length bug
fandreuz Aug 18, 2025
caae8d9
fix full frame
fandreuz Aug 18, 2025
6326534
ops
fandreuz Aug 18, 2025
8b90aef
cc
fandreuz Aug 18, 2025
eb671e9
16
fandreuz Aug 18, 2025
b9b111e
cc
fandreuz Aug 18, 2025
0c5f643
naming
fandreuz Aug 18, 2025
3367834
fix questionmark
fandreuz Aug 18, 2025
ef37fc3
assertion
fandreuz Aug 18, 2025
16a5444
fixes and tests
fandreuz Aug 18, 2025
9c4aaa6
naming
fandreuz Aug 18, 2025
8a2d3fa
fix getSignature
fandreuz Aug 18, 2025
166a31a
new assertion
fandreuz Aug 18, 2025
9937e12
cc
fandreuz Aug 18, 2025
0834abf
ass
fandreuz Aug 18, 2025
e42173e
more bugs
fandreuz Aug 18, 2025
8c8887d
fix wide op
fandreuz Aug 18, 2025
aecae70
review
fandreuz Aug 18, 2025
222a57a
review 2
fandreuz Aug 18, 2025
92bf7c3
review 3
fandreuz Aug 18, 2025
8f0175c
only for latency
fandreuz Aug 19, 2025
29a9132
fix more bugs
fandreuz Aug 19, 2025
9b55cf8
log
fandreuz Aug 19, 2025
b67396e
check logs
fandreuz Aug 19, 2025
1c7915b
fix types
fandreuz Aug 19, 2025
597f16e
9+
fandreuz Aug 19, 2025
62e6547
trigger
fandreuz Aug 19, 2025
d29daed
recursive test is flaky
fandreuz Aug 19, 2025
4801857
ticks
fandreuz Aug 19, 2025
345c2b0
review
fandreuz Aug 19, 2025
87c119d
nn
fandreuz Aug 19, 2025
02fcab5
handle negative
fandreuz Aug 19, 2025
b787640
u32 to u16
fandreuz Aug 19, 2025
8a84d6c
overflow
fandreuz Aug 19, 2025
3f602fc
one less scan
fandreuz Aug 19, 2025
17178f0
fix type warnings
fandreuz Aug 19, 2025
6657ff9
missing include
fandreuz Aug 19, 2025
2487bdc
constant
fandreuz Aug 20, 2025
c2a4d53
jdk8
fandreuz Aug 20, 2025
20a0339
ops
fandreuz Aug 20, 2025
82e8283
nn
fandreuz Aug 20, 2025
7d96540
trigger
fandreuz Aug 20, 2025
fc4a5d3
fix memset
fandreuz Aug 21, 2025
5f649ad
move nops
fandreuz Aug 21, 2025
d6b36ba
fix check
fandreuz Aug 21, 2025
f263b4f
fix formula
fandreuz Aug 21, 2025
3c818a3
docs
fandreuz Aug 22, 2025
5e81c01
rephrase
fandreuz Aug 22, 2025
608d035
prettier
fandreuz Aug 22, 2025
adc75b3
wip
fandreuz Aug 26, 2025
3c015d2
stuff
fandreuz Aug 26, 2025
3beec0f
stuff
fandreuz Aug 26, 2025
ba3feee
cc
fandreuz Aug 26, 2025
c03be95
fix warning
fandreuz Aug 26, 2025
9b0dd55
amend comment
fandreuz Aug 26, 2025
08566b9
separate bit
fandreuz Aug 28, 2025
aead02a
Merge branch 'master' into instrument-method-end
fandreuz Aug 29, 2025
cb3ff13
method id stuff
fandreuz Aug 29, 2025
69a4839
cc test
fandreuz Aug 29, 2025
8aefcbe
cc
fandreuz Aug 29, 2025
d9030f1
int
fandreuz Aug 29, 2025
f9fbc25
missing mutex
fandreuz Aug 29, 2025
a2b8a30
more check
fandreuz Aug 29, 2025
a41ba34
fix segfault
fandreuz Aug 29, 2025
24f7b22
custom mutex
fandreuz Aug 29, 2025
efc7e87
dirty
fandreuz Aug 29, 2025
30fe4e3
ops
fandreuz Aug 29, 2025
57f2b56
revert
fandreuz Aug 29, 2025
df2c713
no name
fandreuz Aug 29, 2025
dc24d7b
Merge branch 'master' into instrument-method-end
fandreuz Aug 29, 2025
e00896d
error name
fandreuz Sep 3, 2025
3f3b9fa
wrong sig
fandreuz Sep 3, 2025
335fc08
bytes
fandreuz Sep 3, 2025
6a0316c
after nofree
fandreuz Sep 3, 2025
6a26796
ap
fandreuz Sep 3, 2025
121f9ba
Update src/instrument.cpp
fandreuz Sep 3, 2025
ec11d8e
else if
fandreuz Sep 3, 2025
bcf3db5
missing param name
fandreuz Sep 3, 2025
994d64c
move to test
fandreuz Sep 3, 2025
b2679d0
let ctor init it
fandreuz Sep 3, 2025
7eb0cc2
switch
fandreuz Sep 3, 2025
21f6b2c
merge branch
fandreuz Sep 3, 2025
e4c707a
missing reset
fandreuz Sep 3, 2025
9a980ab
simplify
fandreuz Sep 3, 2025
69268ad
ptr notation
fandreuz Sep 3, 2025
c3f7e3b
pu32 with ptr
fandreuz Sep 3, 2025
3bed889
fix category
fandreuz Sep 3, 2025
cf1ca95
no getters, hashcode and equals
fandreuz Sep 3, 2025
c5fe0bc
value
fandreuz Sep 3, 2025
3b681a0
fix order
fandreuz Sep 3, 2025
73f9354
both latency and interval
fandreuz Sep 3, 2025
1b9328f
capital
fandreuz Sep 3, 2025
c4738e0
fix sameGroup and hashCode
fandreuz Sep 3, 2025
9f58201
nope
fandreuz Sep 4, 2025
a6f916c
redundant
fandreuz Sep 5, 2025
f9216bf
ugly
fandreuz Sep 5, 2025
9d3dd79
change order
fandreuz Sep 5, 2025
41b2061
inline
fandreuz Sep 5, 2025
49a2016
remove high level
fandreuz Sep 5, 2025
c742f1d
plus
fandreuz Sep 5, 2025
b308fcf
shorter
fandreuz Sep 5, 2025
91fa2f4
2 spaces
fandreuz Sep 5, 2025
ece83eb
pvt
fandreuz Sep 5, 2025
430731d
nn
fandreuz Sep 5, 2025
b210749
out
fandreuz Sep 5, 2025
41554ad
super nit
fandreuz Sep 5, 2025
fda51d2
no repetition
fandreuz Sep 5, 2025
1ae35c7
ops
fandreuz Sep 5, 2025
579e2d6
onlyjumps
fandreuz Sep 5, 2025
2cbfe2a
relocation of base is same as its branches
fandreuz Sep 5, 2025
371439f
down
fandreuz Sep 5, 2025
99dc6b5
linux only
fandreuz Sep 5, 2025
b9769c7
jfr settings
fandreuz Sep 5, 2025
058f7d0
ops
fandreuz Sep 5, 2025
65327e7
fail gracefully
fandreuz Sep 5, 2025
7f217a8
switch and bad
fandreuz Sep 5, 2025
47e1af6
enum
fandreuz Sep 5, 2025
0f9931d
null terminated. member
fandreuz Sep 5, 2025
da0c740
c_str
fandreuz Sep 5, 2025
20cabce
rewriteCodeForLatency only error
fandreuz Sep 5, 2025
dd32de0
ops
fandreuz Sep 5, 2025
f79f1ce
nn
fandreuz Sep 5, 2025
69cc699
Constant
fandreuz Sep 5, 2025
69d4fa2
underscore
fandreuz Sep 5, 2025
bbcdd47
result
fandreuz Sep 5, 2025
75784b9
Minor edits
apangin Sep 5, 2025
d900a34
Minor edits
apangin Sep 5, 2025
2b32d95
Minor edits
apangin Sep 5, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view

There are no files selected for viewing

2 changes: 2 additions & 0 deletions 2 .clang-tidy
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ CheckOptions:
value: '(KB|Thread|setDaemon|klassOop|nVMs|loadLibrary|getTicksFrequency|counterTime|System|M|R|s_)'
- key: readability-identifier-naming.PrivateMemberPrefix
value: _
- key: readability-identifier-naming.ConstexprVariableCase
value: UPPER_CASE
1 change: 1 addition & 0 deletions 1 docs/ProfilerOptions.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The below options are `action`s for async-profiler and common for both `asprof`
| `--live` | `live` | Retain allocation samples with live objects only (object that have not been collected by the end of profiling session). Useful for finding Java heap memory leaks. |
| `--nativemem N` | `nativemem=N` | Native memory allocation profiling. N, if specified is the interval in bytes or in other units, if N is followed by `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). Default N is 0. |
| `--nofree` | `nofree` | Will not record free calls in native memory allocation profiling. This is relevant when tracking memory leaks is not important and there are lots of free calls. |
| `--latency N` | `latency=N` | Duration threshold for Java method latency profiling. Should be a time interval (see `interval` docs for more details). |
| `--lock DURATION` | `lock=DURATION` | In lock profiling mode, sample contended locks when total lock duration overflows the threshold. |
| `--wall INTERVAL` | `wall=INTERVAL` | Wall clock profiling interval. Use this option instead of `-e wall` to enable wall clock profiling with another event, typically `cpu`.<br>Example: `asprof -e cpu --wall 100ms -f combined.jfr 8983`. |
| `-j N` | `jstackdepth=N` | Sets the maximum stack depth. The default is 2048.<br>Example: `asprof -j 30 8983` |
Expand Down
6 changes: 6 additions & 0 deletions 6 docs/ProfilingModes.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ of all compiled methods. The subsequent instrumentation flushes only the _depend

The massive CodeCache flush doesn't occur if attaching async-profiler as an agent.

### Latency profiling

In the context of _Java method profiling_, async-profiler supports latency profiling. Users may
specify a threshold latency with the parameter `latency`. Only the calls exceeding this threshold
in total runtime will be profiled. Method calls resulting in an exception are ignored.

## Native function profiling

Here are some useful native functions to profile:
Expand Down
142 changes: 74 additions & 68 deletions 142 src/arguments.cpp
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -46,74 +46,77 @@ static const Multiplier UNIVERSAL[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'
// The format of the string is:
// arg[,arg...]
// where arg is one of the following options:
// start - start profiling
// resume - start or resume profiling without resetting collected data
// stop - stop profiling
// dump - dump collected data without stopping profiling session
// check - check if the specified profiling event is available
// status - print profiling status (inactive / running for X seconds)
// meminfo - print profiler memory stats
// list - show the list of available profiling events
// version - display the agent version
// event=EVENT - which event to trace (cpu, wall, cache-misses, etc.)
// alloc[=BYTES] - profile allocations with BYTES interval
// live - build allocation profile from live objects only
// lock[=DURATION] - profile contended locks overflowing the DURATION ns bucket (default: 10us)
// wall[=NS] - run wall clock profiling together with CPU profiling
// nobatch - legacy wall clock sampling without batch events
// collapsed - dump collapsed stacks (the format used by FlameGraph script)
// flamegraph - produce Flame Graph in HTML format
// tree - produce call tree in HTML format
// jfr - dump events in Java Flight Recorder format
// jfropts=OPTIONS - JFR recording options: numeric bitmask or 'mem'
// jfrsync[=CONFIG] - start Java Flight Recording with the given config along with the profiler
// traces[=N] - dump top N call traces
// flat[=N] - dump top N methods (aka flat profile)
// otlp - dump in OpenTelemetry format
// samples - count the number of samples (default)
// total - count the total value (time, bytes, etc.) instead of samples
// chunksize=N - approximate size of JFR chunk in bytes (default: 100 MB)
// chunktime=N - duration of JFR chunk in seconds (default: 1 hour)
// timeout=TIME - automatically stop profiler at TIME (absolute or relative)
// loop=TIME - run profiler in a loop (continuous profiling)
// interval=N - sampling interval in ns (default: 10'000'000, i.e. 10 ms)
// jstackdepth=N - maximum Java stack depth (default: 2048)
// signal=N - use alternative signal for cpu or wall clock profiling
// features=LIST - advanced stack trace features (vtable, comptask, pcaddr)"
// safemode=BITS - disable stack recovery techniques (default: 0, i.e. everything enabled)
// file=FILENAME - output file name for dumping
// log=FILENAME - log warnings and errors to the given dedicated stream
// loglevel=LEVEL - logging level: TRACE, DEBUG, INFO, WARN, ERROR, or NONE
// quiet - do not log "Profiling started/stopped" message
// server=ADDRESS - start insecure HTTP server at ADDRESS/PORT
// filter=FILTER - thread filter
// threads - profile different threads separately
// sched - group threads by scheduling policy
// cstack=MODE - how to collect C stack frames in addition to Java stack
// MODE is 'fp', 'dwarf', 'lbr', 'vm' or 'no'
// clock=SOURCE - clock source for JFR timestamps: 'tsc' or 'monotonic'
// alluser - include only user-mode events
// fdtransfer - use fdtransfer to pass fds to the profiler
// target-cpu=CPU - sample threads on a specific CPU (perf_events only, default: -1)
// record-cpu - record which cpu a sample was taken on
// simple - simple class names instead of FQN
// dot - dotted class names
// norm - normalize names of hidden classes / lambdas
// sig - print method signatures
// ann - annotate Java methods
// lib - prepend library names
// mcache - max age of jmethodID cache (default: 0 = disabled)
// include=PATTERN - include stack traces containing PATTERN
// exclude=PATTERN - exclude stack traces containing PATTERN
// begin=FUNCTION - begin profiling when FUNCTION is executed
// end=FUNCTION - end profiling when FUNCTION is executed
// nostop - do not stop profiling outside --begin/--end window
// ttsp - only time-to-safepoint profiling
// title=TITLE - FlameGraph title
// minwidth=PCT - FlameGraph minimum frame width in percent
// reverse - generate stack-reversed FlameGraph / Call tree (defaults to icicle graph)
// inverted - toggles the layout for reversed stacktraces from icicle to flamegraph
// and for default stacktraces from flamegraph to icicle
// start - start profiling
// resume - start or resume profiling without resetting collected data
// stop - stop profiling
// dump - dump collected data without stopping profiling session
// check - check if the specified profiling event is available
// status - print profiling status (inactive / running for X seconds)
// meminfo - print profiler memory stats
// list - show the list of available profiling events
// version - display the agent version
// event=EVENT - which event to trace (cpu, wall, cache-misses, etc.)
// alloc[=BYTES] - profile allocations with BYTES interval
// live - build allocation profile from live objects only
// nativemem[=BYTES] - profile native allocations with BYTES interval
// nofree - do not collect free calls in native allocation profiling
// latency[=DURATION] - Java method latency profiling threshold
// lock[=DURATION] - profile contended locks overflowing the DURATION ns bucket (default: 10us)
// wall[=NS] - run wall clock profiling together with CPU profiling
// nobatch - legacy wall clock sampling without batch events
// collapsed - dump collapsed stacks (the format used by FlameGraph script)
// flamegraph - produce Flame Graph in HTML format
// tree - produce call tree in HTML format
// jfr - dump events in Java Flight Recorder format
// jfropts=OPTIONS - JFR recording options: numeric bitmask or 'mem'
// jfrsync[=CONFIG] - start Java Flight Recording with the given config along with the profiler
// traces[=N] - dump top N call traces
// flat[=N] - dump top N methods (aka flat profile)
// otlp - dump in OpenTelemetry format
// samples - count the number of samples (default)
// total - count the total value (time, bytes, etc.) instead of samples
// chunksize=N - approximate size of JFR chunk in bytes (default: 100 MB)
// chunktime=N - duration of JFR chunk in seconds (default: 1 hour)
// timeout=TIME - automatically stop profiler at TIME (absolute or relative)
// loop=TIME - run profiler in a loop (continuous profiling)
// interval=N - sampling interval in ns (default: 10'000'000, i.e. 10 ms)
// jstackdepth=N - maximum Java stack depth (default: 2048)
// signal=N - use alternative signal for cpu or wall clock profiling
// features=LIST - advanced stack trace features (vtable, comptask, pcaddr)"
// safemode=BITS - disable stack recovery techniques (default: 0, i.e. everything enabled)
// file=FILENAME - output file name for dumping
// log=FILENAME - log warnings and errors to the given dedicated stream
// loglevel=LEVEL - logging level: TRACE, DEBUG, INFO, WARN, ERROR, or NONE
// quiet - do not log "Profiling started/stopped" message
// server=ADDRESS - start insecure HTTP server at ADDRESS/PORT
// filter=FILTER - thread filter
// threads - profile different threads separately
// sched - group threads by scheduling policy
// cstack=MODE - how to collect C stack frames in addition to Java stack
// MODE is 'fp', 'dwarf', 'lbr', 'vm' or 'no'
// clock=SOURCE - clock source for JFR timestamps: 'tsc' or 'monotonic'
// alluser - include only user-mode events
// fdtransfer - use fdtransfer to pass fds to the profiler
// target-cpu=CPU - sample threads on a specific CPU (perf_events only, default: -1)
// record-cpu - record which cpu a sample was taken on
// simple - simple class names instead of FQN
// dot - dotted class names
// norm - normalize names of hidden classes / lambdas
// sig - print method signatures
// ann - annotate Java methods
// lib - prepend library names
// mcache - max age of jmethodID cache (default: 0 = disabled)
// include=PATTERN - include stack traces containing PATTERN
// exclude=PATTERN - exclude stack traces containing PATTERN
// begin=FUNCTION - begin profiling when FUNCTION is executed
// end=FUNCTION - end profiling when FUNCTION is executed
// nostop - do not stop profiling outside --begin/--end window
// ttsp - only time-to-safepoint profiling
// title=TITLE - FlameGraph title
// minwidth=PCT - FlameGraph minimum frame width in percent
// reverse - generate stack-reversed FlameGraph / Call tree (defaults to icicle graph)
// inverted - toggles the layout for reversed stacktraces from icicle to flamegraph
// and for default stacktraces from flamegraph to icicle
//
// It is possible to specify multiple dump options at the same time

Expand Down Expand Up @@ -256,6 +259,9 @@ Error Arguments::parse(const char* args) {
CASE("nofree")
_nofree = true;

CASE("latency")
_latency = value == NULL ? 0 : parseUnits(value, NANOS);

CASE("lock")
_lock = value == NULL ? DEFAULT_LOCK_INTERVAL : parseUnits(value, NANOS);

Expand Down
2 changes: 2 additions & 0 deletions 2 src/arguments.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Arguments {
const char* _event;
int _timeout;
long _interval;
long _latency;
long _alloc;
long _nativemem;
long _lock;
Expand Down Expand Up @@ -220,6 +221,7 @@ class Arguments {
_event(NULL),
_timeout(0),
_interval(0),
_latency(-1),
_alloc(-1),
_nativemem(-1),
_lock(-1),
Expand Down
1 change: 1 addition & 0 deletions 1 src/converter/one/convert/Arguments.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Arguments {
public boolean leak;
public boolean live;
public boolean lock;
public boolean trace;
public boolean threads;
public boolean classify;
public boolean total;
Expand Down
1 change: 1 addition & 0 deletions 1 src/converter/one/convert/JfrConverter.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected void collectEvents() throws IOException {
: args.live ? LiveObject.class
: args.alloc ? AllocationSample.class
: args.lock ? ContendedLock.class
: args.trace ? MethodTrace.class
: ExecutionSample.class;

BitSet threadStates = null;
Expand Down
13 changes: 13 additions & 0 deletions 13 src/converter/one/jfr/JfrReader.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class JfrReader implements Closeable {
private int executionSample;
private int nativeMethodSample;
private int wallClockSample;
private int methodTrace;
private int allocationInNewTLAB;
private int allocationOutsideTLAB;
private int allocationSample;
Expand Down Expand Up @@ -176,6 +177,8 @@ public <E extends Event> E readEvent(Class<E> cls) throws IOException {
if (cls == null || cls == ExecutionSample.class) return (E) readExecutionSample(false);
} else if (type == wallClockSample) {
if (cls == null || cls == ExecutionSample.class) return (E) readExecutionSample(true);
} else if (type == methodTrace) {
if (cls == null || cls == MethodTrace.class) return (E) readMethodTrace();
} else if (type == allocationInNewTLAB) {
if (cls == null || cls == AllocationSample.class) return (E) readAllocationSample(true);
} else if (type == allocationOutsideTLAB || type == allocationSample) {
Expand Down Expand Up @@ -221,6 +224,15 @@ private ExecutionSample readExecutionSample(boolean hasSamples) {
return new ExecutionSample(time, tid, stackTraceId, threadState, samples);
}

private MethodTrace readMethodTrace() {
long startTime = getVarlong();
long duration = getVarlong();
int tid = getVarint();
int stackTraceId = getVarint();
int method = getVarint();
return new MethodTrace(startTime, tid, stackTraceId, method, duration);
}

private AllocationSample readAllocationSample(boolean tlab) {
long time = getVarlong();
int tid = getVarint();
Expand Down Expand Up @@ -552,6 +564,7 @@ private void cacheEventTypes() {
executionSample = getTypeId("jdk.ExecutionSample");
nativeMethodSample = getTypeId("jdk.NativeMethodSample");
wallClockSample = getTypeId("profiler.WallClockSample");
methodTrace = getTypeId("jdk.MethodTrace");
allocationInNewTLAB = getTypeId("jdk.ObjectAllocationInNewTLAB");
allocationOutsideTLAB = getTypeId("jdk.ObjectAllocationOutsideTLAB");
allocationSample = getTypeId("jdk.ObjectAllocationSample");
Expand Down
36 changes: 36 additions & 0 deletions 36 src/converter/one/jfr/event/MethodTrace.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The async-profiler authors
* SPDX-License-Identifier: Apache-2.0
*/

package one.jfr.event;

public class MethodTrace extends Event {
Comment thread
fandreuz marked this conversation as resolved.
Resolved

Uh oh!

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

public final int method;
public final long duration;

public MethodTrace(long time, int tid, int stackTraceId, int method, long duration) {
super(time, tid, stackTraceId);
this.method = method;
this.duration = duration;
}

@Override
public int hashCode() {
return method * 127 + stackTraceId;
}

@Override
public boolean sameGroup(Event o) {
if (o instanceof MethodTrace) {
MethodTrace c = (MethodTrace) o;
return method == c.method;
}
return false;
}

@Override
public long value() {
return duration;
}
}
9 changes: 9 additions & 0 deletions 9 src/event.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum EventType {
WALL_CLOCK_SAMPLE,
MALLOC_SAMPLE,
INSTRUMENTED_METHOD,
METHOD_TRACE,
ALLOC_SAMPLE,
ALLOC_OUTSIDE_TLAB,
LIVE_OBJECT,
Expand All @@ -43,6 +44,14 @@ class ExecutionEvent : public Event {
ExecutionEvent(u64 start_time) : _start_time(start_time), _thread_state(THREAD_UNKNOWN) {}
};

class MethodTraceEvent : public Event {
public:
u64 _start_time;
u64 _duration;

MethodTraceEvent(u64 start_time, u64 duration) : _start_time(start_time), _duration(duration) {}
};

class WallClockEvent : public Event {
public:
u64 _start_time;
Expand Down
Loading
Oops, something went wrong.

Uh oh!

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

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.