Skip to content

Commit

Permalink
feat: support for JFR analysis (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglong1010 authored Feb 23, 2024
1 parent b7d9d31 commit 92a4445
Show file tree
Hide file tree
Showing 116 changed files with 8,913 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
## Introduction

Online Analyzer for Heap Dump, GC Log, and Thread Dump.
Online Analyzer for Heap Dump, GC Log, Thread Dump and JFR.

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

Expand Down
21 changes: 21 additions & 0 deletions analysis/jfr/README.md
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
29 changes: 29 additions & 0 deletions analysis/jfr/jfr.gradle
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'
}
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);
}
}
Loading

0 comments on commit 92a4445

Please sign in to comment.