Code Monkey home page Code Monkey logo

jhiccup's Introduction

jHiccup

Build Status Java CI Gitter


Written by Gil Tene of Azul Systems, and released to the public domain as explained at http://creativecommons.org/publicdomain/zero/1.0


Version: 2.0.10

jHiccup is a non-intrusive instrumentation tool that logs and records platform "hiccups" - including the JVM stalls that often happen when Java applications are executed and/or any OS or hardware platform noise that may cause the running application to not be continuously runnable.

jHiccup can be executed in one of three main ways:

  1. It can be run as a Java agent (using: java -javaagent:jHiccup.jar)

  2. It can be injected into a running application (using: jHiccup -p <pid>)

  3. It can also be run using a convenient wrapper command for your existing Java application (using: jHiccup java myProg ...)


Example jHiccup plot

example plot


Using jHiccup as a Java agent:

jHiccup is most often used as a Java agent. This is useful for platforms and environments where a Java agent is simpler to integrate into launch scripts, or in environments where using the bash jHiccup wrapper script is not practical (e.g. Windows, and environments where java is not directly launched from the command line).

jHiccup.jar can be used as a Java agent using the following launch syntax:

% java -javaagent:jHiccup.jar MyProgram

or

% java -javaagent:jHiccup.jar="<options>" MyProgram.jar -a -b -c

You can find the available options for the Java agent mode by running:

% java -javaagent:jHiccup.jar="-h"

Here is a Java agent usage example with explicit parameters:

% java -javaagent:jHiccup.jar="-d 2000 -i 1000 -l hiccuplog -c" MyProgram.jar -a -b -c

This example will record hiccups experienced during the running of MyProgram.jar in log file hiccuplog, while at the same time recording the hiccups experienced by a control process running in a separate JVM in the log file c.hiccuplog. Measurement will start 2 seconds after startup (rather than immediately), and interval data will be recorded every 1 second (rather than the default 5 seconds).

Useful Java agent related notes:

Note 1: When used as a java agent, jHiccup will treat spaces, commas, and semicolons as delimiting characters ([ ,;]+). For example, the option string -d 0 -i 1000 is equivalent to the option string -d,0,-i,1000. This is useful for environments where placing space delimiters into quoted strings is difficult or confusing.

Note 2: I find that a common way people add jHiccup as a Java agent is by using the _JAVA_OPTIONS environment variable. This often allows one to add the jHiccup Java agent without significant launch script surgery. For example:

export _JAVA_OPTIONS='-javaagent:/path/to/jHiccup/target/jHiccup.jar="-d 20000 -i 1000"'

Reading and processing the jHiccup log with jHiccupLogProcessor:

jHiccup logs hiccup information in a histogram log (see HdrHistogram.org). This histogram log contains a full, high fidelity histogram of all collected results in each interval, in a highly compressed form (typically using only ~200-400 bytes per interval). However, other than the timestamp and maximum hiccup magnitude found in the given interval, the rest of the log line for each interval is not human readable (it is a base64 encoding of a compressed HdrHistogram).

To translate the jHiccup log file to a more human-readable form, the jHiccupLogProcessor utility is provided. In it's simplest form, this utility can be used as such

% jHiccupLogProcessor -i mylog.hlog -o mylog

Which will produce log files mylog and mylog.hgrm containing a human readable interval log (with selected percentiles in each interval), as well as a human readable histogram percentile distribution log.

jHiccupLogProcessor can also be used to produce log files for an arbitrary section of the jHiccup log, by using the optional -start and -end parameters.

See jHiccupLogProcessor -h for more details.


Hiccup Charts: Plotting jHiccup results

Since jHiccup uses HdrHistogram and produces HdrHistogram logs, various tools that plot and view histogram logs can be used to analyze jhiccup data. Some common tools include HistggramLogAnalyzer , HdrHistogramVisualizer
, and a javascript-based in-browser histogram log parser


Launching jHiccup by attaching it to existing, running application:

The jHiccup agent can be injected into a live, running Java application if the environment supports the java attach API (which is typically available in java environments running Java SE 6 or later).

$ jHiccup -p

NOTE: In order to attach to a running java application, the running application needs to have ${JAVA_HOME}/lib/tools.jar in it's classpath. While this is commonly the case already for many IDE and desktop environments, and for environments that involve or enable other attachable agents (such as profilers), you may find that it is not included in your application's classpath, and that it needs to be added if attaching jHiccup at runtime is needed (launching jHiccup as a Java agent per the below may be a good alternative).


Running jHiccup using the Wrapper Script form:

In the wrapper script form, all it takes is adding the word "jHiccup" in front of whatever the java invocation command line is.

For example, if your program were normally executed as:

java <Java args> MyProgram -a -b -c

The launch line would become:

jHiccup java <Java args> MyProgram -a -b -c

or, for a program launched with:

/usr/bin/java <Java args> -jar MyProgram.jar -a -b -c

The launch line would become:

jHiccup /usr/bin/java <Java args> -jar MyProgram.jar -a -b -c

or, to override the defaults by making the recording start delay 60 seconds and log to hlog, it would become:

jHiccup -d 60000 -l hlog /usr/bin/java <Java args> -jar MyProgram.jar -a -b -c

The jar file also includes a simple "Idle" class to facilitate sanity checks without an external program. Here is a simple sanity test example: jHiccup with a 4 sec delay on recording start, wrapping an Idle run that does nothing for 30 seconds and exits:

% jHiccup -d 4000 /usr/bin/java org.jhiccup.Idle -t 30000

[Run jHiccup -h, or see comment in jHiccup script for more details.]


Supported/Tested platforms:

The jHiccup command is expected to work and has been tested on the following platforms:

  • Various Linux flavors (Tested on RHEL/CentOS 5.x and 6.x)
  • Mac OS X (tested on Lion, 10.7)
  • Windows with a Cygwin environment installed (tested on Windows 7)
  • Solaris (tested on both SPARC and x86)

jHiccup.jar is expected to work as a java agent and has been tested on the following platforms:

  • Various Linux flavors (Tested on RHEL/CentOS 5.x and 6.x)
  • Mac OS X (tested on Lion, 10.7)
  • Windows standard command shell (tested on Windows 7)
  • Solaris (tested on both SPARC and x86)

If you use jHiccup on other operating systems and setups, please report back on your experience so that we can expand the list.


Using a control process to concurrently record baseline idle load hiccups:

It is often useful to compare the hiccup behavior experienced by a running application with a "control" hiccup level of an idle workload, running on the same system and at the same time as the observed application. To make such control measurement convenient, jHiccup supports a -c option that will launch a concurrently executing "control process" and will separately log hiccup information of an idle workload running on a separate jvm for the duration of the instrumented application run. When selected, the control process log file name will match those used for the launching application, followed with a .c.

For example:

% jHiccup -l mylog -c /usr/bin/java <Java args> -jar MyProgram.jar -a -b -c

Will produce log file mylog detailing the hiccup behavior during the execution of MyProgram.jar, as well as a log file c.mylog detailing the hiccup behavior of an idle workload running on a separate jvm at the same time.


Log file name recognizes and fills in %pid , %date , and %host terms

When a log file name is specified with the -l option, the terms %pid, %date, and %host will be filled in with the appropriate information. The default log file name setting is simply hiccup.%date.%pid.


Using jHiccup to process latency log files:

jHiccup's main HiccupMeter class supports a mode -f that will take latency input from a file instead of recording it. This is useful for producing jHiccup-style text and graphical output for recorded latency data collected by some other means.

When provided to the -f option, an input file is expected to contain two white-space delimited values per line (in either integer or real number format), representing a time stamp and a measured latency, both in millisecond units.

It's important to note that the default "expected interval between samples" resolution in jHiccup and HiccupMeter is 1 millisecond. When processing input files, it is imperative that an appropriate value be supplied to the -r option, and that this value correctly represent the expected interval between samples in the provided input file. HiccupMeter will use this parameter to determine whether additional, artificial values should be added to the histogram recording, between input samples that are farther apart in time than the expected interval specified to the -r option. This behavior corrects for "coordinated omission" situations (where long response times lead to "skipped" requests that would have typically correlated with "bad" response times). A "large" value (e.g. -r 100000) can easily be specified to avoid any correction of this situation.

Example:

% java -jar jHiccup.jar -i 1000 -f inputLatenies -l latencies.hlog

Using jHiccup to process pause logs from e.g. gc log files:

When run in the file injection mode (-f), jHiccup's main HiccupMeter class supports an optional "fill zeros" (-fz) mode. This mode is useful for processing input that represent pause events rather than latencies.

A common use case for this feature is producing hiccup logs from GC logs. GC logs will generally include pause information, which can be parsed out to a "pauses log". jHiccup can takes a "pauses logs" as input

When provided to the -f option, in conjunction with a -fz option, an input file is expected to contain two white-space delimited values per line (in either integer or real number format), representing a time stamp and a measured length of a pause, both in millisecond units.

Example (parsing gc log with +PrintGCTimeStamps):

% java ... -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCTimeStamps -Xloggc:gc.log ...

% awk -F": " '/Total time for which application threads were stopped/ {printf "%4.0f %4.3f\n", $1*1000.0, $3*1000.0;}' gc.log > gcPauses.log

% java -jar jHiccup.jar -i 1000 -f gcPauses.log -fz -l pauses.hlog

Example (with both +PrintGCTimeStamps and +PrintGCDateStamps):

% java ... -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:gc.log ...
 
% awk -F": " '/Total time for which application threads were stopped/ {printf "%4.0f %4.3f\n", $2*1000.0, $4*1000.0;}' gc.log > gcPauses.log

% java -jar jHiccup.jar -i 1000 -f gcPauses.log -fz -l pauses.hlog

Example: adding jHiccup to Tomcat runs:

In Tomcat's catalina.sh script, replace the following line:

exec "$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS

with:

exec "$JHICCUP_HOME/jHiccup" "$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS

Note: Use of HdrHistogram.

jHiccup depends on and makes systemic use of HdrHistogram to collected and report on the statistical distribution of hiccups. HdrHistogram sources and documentation can be found on GitHub, at http://hdrhistogram.github.io/HdrHistogram/


Building jHiccup:

jHiccup can be (re)built from source files using Maven:

% mvn package

jhiccup's People

Contributors

benhyland avatar bonifaido avatar bryant1410 avatar cesarsotovalero avatar giltene avatar gitter-badger avatar hrj avatar karl82 avatar mich8bsp avatar mikeb01 avatar paplorinc avatar pbzdyl avatar rosshendrickson-wf avatar ryenus avatar scotte avatar snyk-bot avatar sralmai avatar sullis avatar worldofpeace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jhiccup's Issues

Add option to create log in CSV

This would lower the barrier of entry in parsing the data with scripts (i.e. plotting the series in R would be trivial). I'll look at implementing this myself if I can get some time - if so, you can expect a pull request coming your way.

Visualization/log processing tools outdated

Not any of the mentioned log processing tools were able to process my logs

jHiccupLogProcessor, failed to parse logs produced with jhiccup 2.0.10:

./jHiccupLogProcessor -i ~/jhiccup.log -o jhiccup_processed.log
Log file parsing error at line number 0: line appears to be malformed.

Using this file (only gzipped to make attachment smaller):

jhiccup.log.gz

I also tried some other tools linked in the README, none of them worked either:

https://github.com/ennerf/HdrHistogramVisualizer

https://hdrhistogram.github.io/HdrHistogramJSDemo/logparser.html

http://hdrhistogram.github.io/HdrHistogram/plotFiles.html

Please provide an up-to-date list of tools that support the log format of 2.0.10 or instructions on how to convert logs to other formats.

The control process running in a separate JVM is not generated with JDK 9.0.4 and JDK 10

Hi,

We used the following parameters on Linux Centos 3.10.0-514.6.1.el7.x86_64:

-javaagent:/opt/jHiccup-2.0.8/jHiccup.jar=-c,-d,60000,-i,1000,-l,../var/log/program-name.%date

This example should record hiccups experienced during the running of MyProgram.jar in log file hiccuplog, while at the same time recording the hiccups experienced by a control process running in a separate JVM in the log file c.hiccuplog.

The control process running in a separate JVM is not generated with JDK 9.0.4 and JDK 10.0.1.

One single file is generated:

#[Logged with jHiccup version 2.0.8]
#[Histogram log format version 1.3]
#[StartTime: 1524526871.595 (seconds since epoch), Mon Apr 23 23:41:11 UTC 2018]
"StartTimestamp","Interval_Length","Interval_Max","Interval_Compressed_Histogram"
60.007,1.000,0.033,HISTFAAAACV42pNpmSzMwMDAzAABTBDKTwEo5GawYwGD/QeIyDM+JgBnDAWw
61.007,1.000,0.049,HISTFAAAACh42pNpmSzMwMDAygABTBDKT4GBgdnNYMcCBvsPEJF7PEwdTABzmgYy

No issue with JDK 1.8_0_144: two files are generated.

Thanks for your help.

Regards,

Annabelle

Version matching in readme.md

Hello,

it's not a big deal but the Readme.md mentions version 2.0.5 evnev in the 2.0.6 zip archive.

So we don't know if there are big changes between 2.0.5 and 2.0.6.

Kind regards,
Thomas

quick question about Interval_Max

What is the unit or measure for Interval_Max in hiccup.*.hlog file ?
"StartTimestamp","Interval_Length","Interval_Max","Interval_Compressed_Histogram"

Sure looks like milliseconds, but can't find it documented anywhere.

Thanks,
--Erik

Visual Basic index out of bounds exception when generating charts

Using jHiccupPlotter, when generating a chart with default options and no SLA

Run-time error '-2147024809 (80070057)': The index into the specified collection is out of bounds.

This happens in the following line inside the drawIntervalChart method.

ch.SeriesCollection.Add Source:=Sheets(sourceSheetName).Range("A1")

Here is the hlog and files generated by the log processor
logs.zip

Interval_Max extending past runtime of jHiccup Jar file

Hello all,

I've been using jHiccup on close to a 5 min interval to listen for pausing on a bare-metal linux machine.

java -jar jHiccup.jar -t 295000

Normally the pausing stays within a pretty small timeframe, but on one of the files we had a pause of 5841155.523. Accounting for it being in milliseconds this is still 5,841.15 seconds which is way over my 5 min interval the profiler runs for.

I was wondering if we might know what occurred to cause this?

Attached is the .hlog file in question along with an example of a normal run for my process.
suspect_file.csv
normal_run.csv

Improvement of sleep in loop

Hi, I found an interesting case in this project.
It has “Thread.sleep()” in a “while(true)” loop. I found some discussion in Stackoverflow and other website. It can be refactored by using a executor service.
https://ejrh.wordpress.com/2012/07/13/sleeping-in-loops-considered-harmful/
https://stackoverflow.com/questions/3535754/netbeans-java-new-hint-thread-sleep-called-in-loop
or
Maybe use CountDownLatch.await to automatically awake and shutdown.

Detailed websites and lines:

620 | https://github.com/giltene/jHiccup/blob/master/src/main/java/org/jhiccup/HiccupMeter.java

Best regards

Wrapper doesn't work as documented

The wrapper script example of:

jHiccup /usr/bin/java -jar MyProgram.jar -a -b -c

Doesn't work. The only way this works is if options are given to jHiccup.

For example:

$ jHiccup java -version
Error: launched with the following args:

Which was parsed as an error, indicated by the following exception:
java.lang.Exception: Invalid args:
[...]

But this works:

$ jHiccup -d 0 java -version

Looks like a bug in the option parsing where options are not, in fact, optional.

How to use jHiccup with Solr?

I've tried use Solr with Jhiccup to analyze garbage collectors of Azul zing JVM and G1GC of Java-Hotspot. I launched solr, and want include jHiccup on it. of solr process is 1078. I used following command: ./jHiccup -l /tmp/jHiccup-2.0.9/hiccup.%date.%pid -p 1078. It should be work, but an error is displayed : A JNI error has occured, please check your installation and try again. Help me please!

failing to connect to remote process

Trying to use jHiccup to monitor a Cassandra process but getting an error. Is there a way to attach? Or what are my alternative ways to monitor using jHiccup?

$ locate tools.jar
/usr/java/jdk1.7.0_76/lib/tools.jar
$ ps jfax | egrep java
1 20400 20337 20337 ? -1 SLl 397 36362:24 /usr/java/jdk1.7.0_76/jre/bin/java -ea -javaagent:/usr/share/cassandra/lib/jamm-0.3.0.jar ...
$ sudo ./jHiccup -p 20400
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded

Help requested on how to achieve log file rotation with jHiccup logs?

Hi Gil,
Could you please guide me on the following

  • How can I achieve log file rotation after the log has reached a specific size limit. I understand we can add %pid_%host_%date to the log file name. But that I assume will not get rolled over, until the application restarts?
  • The intention is to run jHiccup on a application under load (high volume) running on a pod, that might have disk capacity restrictions. Could you please help me on what extra disk capacity is required assuming jHiccup runs inside such a high volume application.
  • Also , if you have a rough guideline on the size of the generated log, based on duration of run, it would be great.
    Thanks in Advance,
    Divya

Statsd/graphite output

We're going to use statsd+graphite for monitoring, and I'd like to see data collected by jhiccup there as well. Would it be possible to send data to statsd/graphite instead of logging it to a file?

Logging timestamps

After chatting with an Azul engineer, it was suggested I create this issue to ask for a clarification in the documentation (if no code change is needed) to describe which clocks are being used when printing otu the log line and which clocks are being used to measure pauses (System.currentTimeMillis() and System.naonTime() respectively).

We have an issue (still unsolved at this point) where there was a 35s delta between two log lines (lines before and after are 1s apart). The maximum seen pause during this iteration was only 0.688 which wouldn't seem to be possible if the log line's clock showed a diff of 35s.

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.