Skip to content

Enable the use of JFR at native-image build time #4094

@zakkak

Description

@zakkak

Feature request

Enable the use of Java Flight Recorder (JFR) to profile the native image driver itself, i.e. by passing -J-XX:StartFlightRecording to native-image.

Is your feature request related to a problem? Please describe.

Being able to profile and better understand what's happening during native-image generation is a key prerequisite in optimizing it.

Describe the solution you'd like.

We should be able to pass -J-XX:StartFlightRecording to native-image and enable profiling of the native image driver on the host VM, this however should not impact the code being compiled to native image.

Ideally passing -J-XX:StartFlightRecording to native-image should also be compatible with -H:+AllowVMInspection.

Describe who do you think will benefit the most.
GraalVM contributors.

Additional context.

The issues observed that far are:

  1. Passing -J-XX:StartFlightRecording alters the behavior of the code being compiled by native-image, e.g. java.lang.Error.<init> is being compiled with embed JFR instrumentation calls while an instrumented java.lang.Error.<init> should only be used on the host JVM.
  2. Passing -J-XX:StartFlightRecording results in various JFR-related classes being initialized and embed in the image heap. This not only results in larger image sizes but also breaks JFR support in the generated native image since various elements of JFR get preconfigured at build-time.

Express whether you'd like to help contributing this feature

Yes

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions