Skip to content
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.

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

Enable JFR continuous profiling with default setting #7006

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ahamlat
Copy link
Contributor

@ahamlat ahamlat commented Apr 28, 2024

PR description

Enable JFR continuous profiling with default setting.
Java Flight Recorder (JFR) serves as an integrated mechanism within the Java Virtual Machine (JVM) for gathering, analyzing, and profiling information regarding the performance and memory usage of Java applications. Its design ensures minimal impact on performance, making it suitable for deployment in high-demand production settings.
With default setting, the impact on performance is less than 1 %.

Once the recording in place, we can either dump the recording from the last restart knowing that the recording is limited to 250 MiB, or start a second recording to have a recording you small set of data and in a controlled period.

Configure the recording with default setting profile
BESU_OPTS=-XX:StartFlightRecording,dumponexit=true,settings=default.jfc

Check the recording
sudo jcmd PID JFR.check

Start a parallel recording
sudo jcmd PID JFR.start

Dump the profiling to a file
Dump the default recording : sudo jcmd PID JFR.dump name=1 filename=FILEPATH
Dump the parallel recording : sudo jcmd PID JFR.dump name=2 filename=FILEPATH

Fixed Issue(s)

#6957

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
…d when we want to dump the file.

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
@ahamlat
Copy link
Contributor Author

ahamlat commented May 2, 2024

Sharing some tests here :

ahamlat@dev-elc-besu-***:/opt/besu/besu-with-profiling$ sudo jcmd 433466 JFR.check
433466:
Recording 1: name=1 maxsize=250.0MB (running)
ahamlat@dev-elc-besu-***:/opt/besu/besu-with-profiling$ sudo jcmd 433466 JFR.dump name=1 filename=/tmp/recording.jfr
433466:
Dumped recording "1", 4.2 MB written to:

/tmp/recording.jfr
ahamlat@dev-elc-besu-***:/opt/besu/besu-with-profiling$ sudo jcmd 433466 JFR.start
433466:
Started recording 2. No limit specified, using maxsize=250MB as default.

Use jcmd 433466 JFR.dump name=2 filename=FILEPATH to copy recording data to file.
ahamlat@dev-elc-besu-***:/opt/besu/besu-with-profiling$ sudo jcmd 433466 JFR.check
433466:
Recording 1: name=1 maxsize=250.0MB (running)

Recording 2: name=2 maxsize=250.0MB (running)
ahamlat@dev-elc-besu-***:/opt/besu/besu-with-profiling$ sudo jcmd 433466 JFR.dump name=2 filename=/tmp/recording2.jfr
433466:
Dumped recording "2", 2.0 MB written to:

/tmp/recording2.jfr

@ahamlat
Copy link
Contributor Author

ahamlat commented May 2, 2024

There is still one small issue that happens with java 17, but not with java 21. The JVM displays in the output dumponexit=true,settings=default.jfc which is not great in terms of user experience, when for example we want to display Besu version :

bin/besu --version
dumponexit=true,settings=default.jfc
besu/v24.5-develop-c6c6dab/linux-x86_64/openjdk-java-17

This is actually what is making some of the acceptance tests fail, ex. besu --help command test

@ahamlat
Copy link
Contributor Author

ahamlat commented May 2, 2024

It is simple to reproduce even with only Java --version

Java 17

java -XX:StartFlightRecording -Xlog:jfr*=off -version
dumponexit=false
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-122.04.1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Ubuntu-122.04.1, mixed mode, sharing)

Java 21

java -XX:StartFlightRecording -Xlog:jfr*=off -version
openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-Ubuntu-122.04.1)
OpenJDK 64-Bit Server VM (build 21.0.2+13-Ubuntu-122.04.1, mixed mode, sharing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant