-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for JFR analysis (#252)
- Loading branch information
1 parent
b7d9d31
commit 92a4445
Showing
116 changed files
with
8,913 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# JFR Analysis | ||
|
||
Profiling is a type of runtime analysis. Java Flight Recorder (JFR) is the builtin Profiler for Java. It collects data on the fly and generates JFR files. JFR analysis gives you a birds-eye view of what is happening inside Java, such as CPU usage, memory allocation, and other activities of threads. | ||
|
||
### Supported Format | ||
|
||
- OpenJDK JFR (binary format) | ||
|
||
### Feature List | ||
|
||
The supported features are as follows: | ||
|
||
- CPU | ||
- Allocation | ||
- Wall Clock (Only JFR files created by async-profiler with wall engine) | ||
- File IO | ||
- Socket IO | ||
- Lock | ||
- Class Load | ||
- Thread Sleep | ||
- Native Execution Sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
********************************************************************************/ | ||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
apply from: "$rootDir/gradle/java.gradle" | ||
|
||
jar { | ||
archiveBaseName.set("jfr") | ||
} | ||
|
||
dependencies { | ||
api project(':analysis') | ||
implementation 'org.openjdk.jmc:flightrecorder:8.2.0' | ||
implementation 'org.openjdk.jmc:flightrecorder.rules:8.2.0' | ||
implementation 'org.openjdk.jmc:flightrecorder.rules.jdk:8.2.0' | ||
implementation group: 'org.ow2.asm', name: 'asm', version: '9.3' | ||
} |
63 changes: 63 additions & 0 deletions
63
analysis/jfr/src/main/java/org/eclipse/jifa/jfr/JFRAnalysisApiExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.jifa.jfr; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.eclipse.jifa.analysis.AbstractApiExecutor; | ||
import org.eclipse.jifa.analysis.listener.ProgressListener; | ||
import org.eclipse.jifa.analysis.support.MethodNameConverter; | ||
import org.eclipse.jifa.jfr.api.JFRAnalyzer; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Map; | ||
import java.util.function.Predicate; | ||
|
||
@Slf4j | ||
public class JFRAnalysisApiExecutor extends AbstractApiExecutor<JFRAnalyzer> { | ||
@Override | ||
public String namespace() { | ||
return "jfr-file"; | ||
} | ||
|
||
@Override | ||
public Predicate<byte[]> matcher() { | ||
return new Predicate<>() { | ||
static final String HEADER = "FLR"; | ||
|
||
@Override | ||
public boolean test(byte[] bytes) { | ||
return bytes.length > HEADER.length() && new String(bytes, 0, HEADER.length()).equals(HEADER); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean needOptionsForAnalysis(Path target) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void clean(Path target) { | ||
super.clean(target); | ||
} | ||
|
||
@Override | ||
protected MethodNameConverter methodNameConverter() { | ||
return MethodNameConverter.GETTER_METHOD; | ||
} | ||
|
||
@Override | ||
protected JFRAnalyzer buildAnalyzer(Path target, Map<String, String> options, ProgressListener listener) { | ||
return new JFRAnalyzerImpl(target, options, listener); | ||
} | ||
} |
Oops, something went wrong.