forked from giltene/jHiccup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
234 lines (166 loc) · 9.94 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
jHiccup:
# Written by Gil Tene of Azul Systems, and released to the public domain,
# as explained at http://creativecommons.org/publicdomain/zero/1.0/
#
# Version: 1.3.8
----------------------------------------------------------------------------
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 ...)
Using jHiccup:
----------------------------------------------------------------------------
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 0 -i 1000 -l hiccuplog -c" MyProgram.jar -a -b -c
This example will record hiccups experienced during the running of MyProgram.jar
in log files hiccuplog and hiccuplog.hgrm, while at the same time recording the
hiccups experienced by a control process running in a separate JVM in log files
c.hiccuplog and c.hiccuplog.hgrm. Measurement will start immediately upon
startups (rather than the 30 second default delay), and interval
data will be records 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/bin/jHiccup.jar="-d 20000 -i 1000"'
----------------------------------------------------------------------------
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 <pid>
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 logfiles hlog and hlog.hgrm, 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.]
----------------------------------------------------------------------------
Hiccup Charts: Plotting jHiccup results
A jHiccupPlotter.xls Excel spreadsheet is included to conveniently
plot jHiccup log files in "Hiccup Chart" form. To use the spreadsheet,
load it into Excel, (make sure to enable macros), and follow the 2-step
instructions in main menu worksheet to automatically import the log files
and produce the Hiccup Chart.
----------------------------------------------------------------------------
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 files mylog and mylog.hgrm detailing the hiccup behavior
during the execution of MyProgram.jar, as well as log files mylog.c and
mylog.c.hgrm 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 and %date terms
When a log file name is specified with the -l option, the terms %pid and
%date 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 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: 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. This package includes an
HdrHistogram.jar jar file to support this functionality. HdrHistogram sources,
documentation, and a ready to use jar file can all be found on GitHub, at
http://giltene.github.com/HdrHistogram
----------------------------------------------------------------------------
Building jHiccup:
jHiccup can be (re)built from source files using Maven:
% mvn package
This file was modified by IntelliJ IDEA 12.1.6 for binding GitHub repository