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 — Support JFR event settings in jfrsync by MrChang0 · Pull Request #1796 · async-profiler/async-profiler

Conversation

@MrChang0

@MrChang0 MrChang0 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Support JFR event settings in explicit jfrsync event lists:

--jfrsync '+jdk.JavaExceptionThrow#stackTrace=true'

The existing +event syntax remains unchanged.

Related issues

Closes #1793

Motivation and context

This allows configuring settings such as stackTrace and threshold without creating and distributing a custom .jfc file.

How has this been tested?

Added an integration test that verifies stack traces are recorded for jdk.JavaExceptionThrow. Tested on JDK 11 and JDK 21.


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
apangin
apangin reviewed Aug 28, 2026
View reviewed changes
Comment thread docs/ProfilerOptions.md Outdated
| `--ratelimit LIMITS` | `ratelimit=LIMITS` | Limit the number of JFR events emitted per second. `LIMITS` is a list of `CATEGORY:LIMIT` pairs, where `CATEGORY` is one of `cpu`, `alloc`, `lock`, `wall`, `nativemem`, `nativelock`, `trace`, `span`. Event types of the same category share a single per-second budget; events exceeding the budget are discarded. Unused budget carries over to the next second, allowing short bursts up to 2x limit.<br>Example: `asprof -e cpu,alloc -f profile.jfr --ratelimit cpu:1000,alloc:200,span:100 8983`<br>As an agent option, separate pairs with `;` instead of `,` |
| `--jfropts OPTIONS` | `jfropts=OPTIONS` | Comma separated list of JFR recording options. Currently, the only available option is `mem` supported on Linux 3.17+. `mem` enables accumulating events in memory instead of flushing synchronously to a file. |
| `--jfrsync CONFIG` | `jfrsync[=CONFIG]` | Start Java Flight Recording with the given configuration synchronously with the profiler. The output .jfr file will include all regular JFR events, except that execution samples will be obtained from async-profiler. This option implies `-o jfr`.<br>`CONFIG` is a predefined JFR profile or a JFR configuration file (.jfc) or a list of JFR events started with `+`.<br>Example: `asprof -e cpu --jfrsync profile -f combined.jfr 8983` |
| `--jfrsync CONFIG` | `jfrsync[=CONFIG]` | Start Java Flight Recording with the given configuration synchronously with the profiler. The output .jfr file will include all regular JFR events, except that execution samples will be obtained from async-profiler. This option implies `-o jfr`.<br>`CONFIG` is a predefined JFR profile, a JFR configuration file (.jfc), or a list of JFR events started with `+`. Event settings may be specified as `+event#setting=value`.<br>Example: `asprof -e cpu --jfrsync '+jdk.JavaExceptionThrow#stackTrace=true' -f combined.jfr 8983` |

@apangin apangin Aug 28, 2026

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.

Does it make sense to enable stackTrace for all custom events by default?

Sorry, something went wrong.

Uh oh!

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

All reactions

@MrChang0 MrChang0 Aug 31, 2026

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.

Adjusted the description :)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/helper/one/profiler/JfrSync.java Outdated
}

int equals = event.indexOf('=', separator + 1);
if (separator == 0 || equals <= separator + 1 || equals == event.length() - 1) {

@apangin apangin Aug 28, 2026

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.

This is too strict. Empty string is a perfectly valid value for certain settings, e.g. MethodTrace#filter.
In general, over-defensive programming is considered bad style in this repository. Even JDK standard API accepts

rec.enable("jdk.JavaExceptionThrow").with("", "")

so why should async-profiler reject it?

Sorry, something went wrong.

Uh oh!

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

All reactions

@MrChang0 MrChang0 Aug 31, 2026

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.

Agreed. I removed the validation and now treat a missing = as an empty value, so +jdk.MethodTrace#filter is accepted. I also added it to the test.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread test/test/jfr/ExceptionThrow.java Outdated

public static void main(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < 2000) {

@apangin apangin Aug 28, 2026

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.

Why wait for 2 seconds? Does it matter for this test if we throw 1 or 100000 exceptions?

Sorry, something went wrong.

Uh oh!

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

All reactions

@MrChang0 MrChang0 Aug 31, 2026

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.

Agree. Simplified the test to throw only one exception.

Sorry, something went wrong.

Uh oh!

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

All reactions
@MrChang0
MrChang0 force-pushed the jfrsync-event-settings branch from e73be0f to 6f33b6c Compare August 31, 2026 03:33
apangin
apangin reviewed Sep 3, 2026
View reviewed changes
Comment thread src/helper/one/profiler/JfrSync.java Outdated

int equals = event.indexOf('=', separator + 1);
if (equals < 0) {
event += '=';

@apangin apangin Sep 3, 2026

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.

This is long and inefficient.
A simpler way to do the same would be something like

int eq = event.indexOf('=', separator + 1);
String setting = eq >= 0 ? event.substring(separator + 1, eq) : event.substring(separator + 1);
String value = eq >= 0 ? event.substring(eq + 1) : "";

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/helper/one/profiler/JfrSync.java
private static void enableEvent(Recording recording, String event) {
int separator = event.indexOf('#');
if (separator < 0) {
recording.enable(event);

@apangin apangin Sep 3, 2026

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.

I mean, why don't enable stackTraces by default for all custom events as they are already enabled in standard JFR profiles? So that users don't have to add #stackTrace=true every time.

Sorry, something went wrong.

Uh oh!

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

All reactions

@MrChang0 MrChang0 Sep 16, 2026

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.

Agreed. I've prepared a minimal local update using withStackTrace() when enabling each event, followed by the requested setting. It deliberately does not preserve #stackTrace=false across later entries for the same event; those entries can re-enable stack traces. This keeps the change small without additional state tracking.

Sorry, something went wrong.

Uh oh!

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

All reactions

@apangin apangin Sep 16, 2026

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.

This turned out to be a bad idea. Not all events have a meaningful stack trace (e.g. jdk.ExceptionStatistics). Also, if multiple settings were specified and stackTrace was set to false in the first one, the second setting would reset stackTrace back to true.

I reverted the change.

Sorry, something went wrong.

Uh oh!

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

All reactions
MrChang0 added 3 commits September 16, 2026 15:47
@MrChang0
Support JFR event settings in jfrsync
4232a27
@MrChang0
Allow JFR event settings without values
a953bd6
@MrChang0
Enable stack traces by default for jfrsync events
6fa7123
@MrChang0
MrChang0 force-pushed the jfrsync-event-settings branch from 67c5558 to 6fa7123 Compare September 16, 2026 07:47
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

linux-x64

File Base (KiB) Treatment (KiB) Delta (KiB) % Change
bin/asprof 81.72 81.72 +0.00 +0.00%
bin/jfrconv 136.53 136.53 +0.00 +0.00%
lib/libasyncProfiler.so 581.69 585.69 +4.00 +0.69%

linux-arm64

File Base (KiB) Treatment (KiB) Delta (KiB) % Change
bin/asprof 89.59 89.59 +0.00 +0.00%
bin/jfrconv 136.53 136.53 +0.00 +0.00%
lib/libasyncProfiler.so 609.22 609.22 +0.00 +0.00%

macos

File Base (KiB) Treatment (KiB) Delta (KiB) % Change
bin/asprof 116.74 116.74 +0.00 +0.00%
bin/jfrconv 136.53 136.53 +0.00 +0.00%
lib/libasyncProfiler.dylib 969.57 969.57 +0.00 +0.00%
All reactions

Sorry, something went wrong.

Uh oh!

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

MrChang0 and others added 2 commits September 16, 2026 22:01
@MrChang0
Fix JFR options table formatting
da78038
@apangin
Reverted stackTrace-by-default change
95ce513
@apangin
apangin merged commit a4c26af into async-profiler:master Sep 16, 2026
26 checks passed

Uh oh!

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

@apangin

apangin commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Fix merged. Thank you for the contribution.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bryan-minimal bryan-minimal mentioned this pull request Oct 27, 2026
async-profiler: pkgscan allowlist for upstream's committed JfrSync.class (4.6) gominimal/pkgs#1129
Merged
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

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.

Support JFR event settings in --jfrsync

Uh oh!

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

2 participants

@MrChang0 @apangin
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.