Skip to content

Commit 92a4445

Browse files
authored
feat: support for JFR analysis (eclipse-jifa#252)
1 parent b7d9d31 commit 92a4445

File tree

116 files changed

+8913
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+8913
-16
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
## Introduction
2121

22-
Online Analyzer for Heap Dump, GC Log, and Thread Dump.
22+
Online Analyzer for Heap Dump, GC Log, Thread Dump and JFR.
2323

2424
Please refer to [GitHub Pages](https://eclipse.github.io/jifa) for more information.
2525

Diff for: analysis/jfr/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# JFR Analysis
2+
3+
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.
4+
5+
### Supported Format
6+
7+
- OpenJDK JFR (binary format)
8+
9+
### Feature List
10+
11+
The supported features are as follows:
12+
13+
- CPU
14+
- Allocation
15+
- Wall Clock (Only JFR files created by async-profiler with wall engine)
16+
- File IO
17+
- Socket IO
18+
- Lock
19+
- Class Load
20+
- Thread Sleep
21+
- Native Execution Sample

Diff for: analysis/jfr/jfr.gradle

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/********************************************************************************
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
********************************************************************************/
13+
plugins {
14+
id 'java-library'
15+
}
16+
17+
apply from: "$rootDir/gradle/java.gradle"
18+
19+
jar {
20+
archiveBaseName.set("jfr")
21+
}
22+
23+
dependencies {
24+
api project(':analysis')
25+
implementation 'org.openjdk.jmc:flightrecorder:8.2.0'
26+
implementation 'org.openjdk.jmc:flightrecorder.rules:8.2.0'
27+
implementation 'org.openjdk.jmc:flightrecorder.rules.jdk:8.2.0'
28+
implementation group: 'org.ow2.asm', name: 'asm', version: '9.3'
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/********************************************************************************
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
********************************************************************************/
13+
package org.eclipse.jifa.jfr;
14+
15+
import lombok.extern.slf4j.Slf4j;
16+
import org.eclipse.jifa.analysis.AbstractApiExecutor;
17+
import org.eclipse.jifa.analysis.listener.ProgressListener;
18+
import org.eclipse.jifa.analysis.support.MethodNameConverter;
19+
import org.eclipse.jifa.jfr.api.JFRAnalyzer;
20+
21+
import java.nio.file.Path;
22+
import java.util.Map;
23+
import java.util.function.Predicate;
24+
25+
@Slf4j
26+
public class JFRAnalysisApiExecutor extends AbstractApiExecutor<JFRAnalyzer> {
27+
@Override
28+
public String namespace() {
29+
return "jfr-file";
30+
}
31+
32+
@Override
33+
public Predicate<byte[]> matcher() {
34+
return new Predicate<>() {
35+
static final String HEADER = "FLR";
36+
37+
@Override
38+
public boolean test(byte[] bytes) {
39+
return bytes.length > HEADER.length() && new String(bytes, 0, HEADER.length()).equals(HEADER);
40+
}
41+
};
42+
}
43+
44+
@Override
45+
public boolean needOptionsForAnalysis(Path target) {
46+
return false;
47+
}
48+
49+
@Override
50+
public void clean(Path target) {
51+
super.clean(target);
52+
}
53+
54+
@Override
55+
protected MethodNameConverter methodNameConverter() {
56+
return MethodNameConverter.GETTER_METHOD;
57+
}
58+
59+
@Override
60+
protected JFRAnalyzer buildAnalyzer(Path target, Map<String, String> options, ProgressListener listener) {
61+
return new JFRAnalyzerImpl(target, options, listener);
62+
}
63+
}

0 commit comments

Comments
 (0)