Giter Site home page Giter Site logo

perfj's Introduction

PerfJ

Join the chat at https://gitter.im/coderplay/perfj

PerfJ is a wrapper of linux perf for java programs.

As Brendan Gregg's words

In order to profile java programs, you need a profiler that can sample stack traces. There has historically been two types of profilers:

  • System profilers: like Linux perf, which shows system code paths (eg, JVM GC, syscalls, TCP), but not Java methods.
  • JVM profilers: like hprof, LJP, and commercial profilers. These show Java methods, but usually not system code paths.

Ideally, we need a profile result that does it all: system and Java code paths. Apart from convenience, it also shows system code-paths in Java context, which can be crucial for understanding a profile properly.

The problem is getting a system profiler to understand Java methods and stack traces. If you try Linux perf_events, for example, you'll see hexadecimal numbers and broken stack traces, as it can't convert addresses into Java symbols, and can't walk the JVM stack.

There are two specific problems:

  • The JVM compiles methods on the fly (just-in-time: JIT), and doesn't expose a traditional symbol table for system profilers to read.
  • The JVM also uses the frame pointer register (RBP on x86-64) as a general purpose register, breaking traditional stack walking.

Thanks to the work by Brendan Gregg and Zoltan Majo. We will have an option to turn on the preservation of frame pointer on JDK 8u60+.

This project is based on Johannes Rudolph's work at here, but PerfJ is more convenient and safer to use.

PerfJ can produce flame graph through Brendan Gregg's FlameGraph tool .

Below is an example shows the hotspot of a pure java leveldb program. Green is Java layer, yellow is JVM layer, and red is system layer(native user-level, or kernel). Longer bar means higher cpu percentage.

PerfJ CPU Flame Graph Example

There is a raw interactive SVG image [here] (http://blog.minzhou.info/perfj/perfj.svg).

Prerequisites

  • Linux x86_64
  • perf
  • JDK 8u60 and higher

Build

Before starting building PerfJ, make sure gcc is already installed.

checkout the source from github

git clone https://github.com/coderplay/perfj.git

and run below in the future building

cd perfj
./gradlew releaseTarGz

Installation

Before install PerfJ, you should install Linux perf first

To install perf on centos/redhat/fedora linux system

yum install perf.x86_64

To install perf on ubuntu linux system

apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r`

then download perfj-*.tgz from the [release page] (https://github.com/coderplay/perfj/releases), untar it

tar zxvf perf-*.tgz

Usage

Check the [wiki pages] (https://github.com/coderplay/perfj/wiki)

License

This library is licensed under GPLv2. See the LICENSE file.

perfj's People

Contributors

coderplay avatar gitter-badger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.