SlideShare a Scribd company logo
IBM Java Health Center



         Kevin Grigorenko (IBM WAS SWAT Team)
         kevin.grigorenko@us.ibm.com



                                           © 2012 IBM Corporation
IBM Java Health Center
 The IBM Java Health Center is a very low overhead tool
    that runs in the IBM JVM and provides information on
    method profiling, garbage collection, I/O, lock analysis,
    threads, native memory, and more.
 Fully supported by the IBM Java Tools team through PMRs.
 Important Links:
    – Product Page: http://www.ibm.com/developerworks/java/jdk/tools/healthcenter/
    – Documentation: http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/introduction.html

 Similar to HotSpot/Oracle's VisualVM and JRockit Mission Control
 It runs with the IBM JVM (32- or 64-bit) on: AIX, Linux, Windows, and
    z/OS.



2                                                                                                                          © 2012 IBM Corporation
When to Use Health Center
 Health Center is particularly good for deep dives into
    performance issues, high CPU and monitor contention.
 It does not have the overall capabilities of monitoring
    products such as ITCAM.
 The sampling profiler currently has lower overhead than
    monitoring products due to very tight coupling with IBM
    JVM internals and bypassing of JVMTI interfaces.
    – Overhead of sampling profiler usually as low as < 1% or 2%




3                                                           © 2012 IBM Corporation
Agent & Client
 The Health Center Agent is a JVMTI native library that
    must be enabled (off by default)
    – Most often enabled using a generic JVM argument -Xhealthcenter
      or -Xhealthcenter:level=headless and restarting the JVM
    – Recent versions can be enabled dynamically using late attach
    – Two modes: 1) Connected to a client through a socket, 2)
      headless
 The Health Center Client is an Eclipse-based GUI
    perspective which is used to analyze agent data
    – Two modes: 1) Connected to the agent through a socket, 2) load
      HCD file produced by the agent or exported from another client


4                                                           © 2012 IBM Corporation
Agent: Getting Started
 The IBM JVM ships with Health Center:
    – …/java/jre/lib/$PLATFORM/libhealthcenter.so
    – …/java/jre/lib/ext/healthcenter.jar
    – …/java/jre/lib/healthcenter.properties
    – …/java/jre/bin/libhealthcenter.so
 Health Center performance and functionality is affected
    by two things: 1) the version & service release of the JVM,
    and 2) the version of the agent
    – If practical, it's always best to update the agent because the agent
      is independent of the JVM and the latest will have bug fixes,
      additional collection, better command line options, etc.


5                                                              © 2012 IBM Corporation
Minimum JVM Version for Agent Use in Production
 Platform requirements:
     – http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/platforms.html


    IBM Java     Minimum              Minimum WAS                 Owned           Native          Enable           Allocation
    Version      Service Release      Release for use in          Monitor         Memory          verbosegc        Sampling
                 for use in           production                  Information     Breakdown       at runtime
                 Production
    Java 5
                                                                                                                   
                 SR10                 WAS 6.1.0.27



                 SR5                  WAS 7.0.0.5
    Java 6
                                                                                                                   
                                                                                                                   
    Java 626     Any                  WAS 8.0




                                                                                                                   
    Java 7       Any                  WAS 8.5




6                                                                                                            © 2012 IBM Corporation
Checking the Installed Agent Version
 Two ways to figure out the installed version:
    – Run java -version -Xhealthcenter
     • $ …/java/bin/java -version -Xhealthcenter
       – …
         Feb 14, 2012 11:06:56 AM
         com.ibm.java.diagnostics.healthcenter.agent.mbean.HCLaunchMBean
         startAgent
         INFO: Agent version "1.3.0.20101014"
    – Extract version.properties from …/java/jre/lib/ext/healthcenter.jar
     • $ jar xvf …/java/jre/lib/ext/healthcenter.jar version.properties
     • $ cat version.properties
       – jar.version=1.3.0.20101014




7                                                                     © 2012 IBM Corporation
Getting the Latest Agent
 Three ways to get the latest agent:
    – Health Center Documentation Page:
     http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/installingagent.html


    – From within IBM Support Assistant, click Help > Help Contents >
      … Health Center > … Installing the Health Center Agent
    – Internal, IBM-only builds:
     http://chevalier.hursley.ibm.com/javatb/downloads/healthcenter/healthcenterdownloads.html

 The agent bitness (32- or 64-bit) should match the JVM
    bitness, not the operating system bitness.
     • For example, if it is a 32-bit JVM running on a 64-bit operating system,
       download the 32-bit agent.




8                                                                                                                    © 2012 IBM Corporation
Updating the Agent
 Some customers are weary about updating the WAS installation files;
    however, the files being updated do not relate to non-Health Center
    functionality.
 Consider backing up the existing agent files in case there are problems.
 Procedure (for z/OS, see documentation)
    – Upload the ZIP file to <WAS>/java/$FILE.zip
    – Change directory to <WAS>/java/ and run the command:
      • ./bin/jar xvf $FILE.zip
    – Make sure to chown the updated files properly.
    – Error “in use” because you just tried running health center (e.g. checking
      the version) and on some operating systems, may persist unless all
      related Java processes are stopped.
      • If it still doesn't work, and the JVM is run by a non-root user, then try extracting
        the zip using the root user, and then chown to the non-root user.
9                                                                             © 2012 IBM Corporation
Enabling the Agent
 There are three modes:
     – Socket Communication (-Xhealthcenter)
       •   By default opens port 1972 or the first available increment up to 2072
       •   Communication either in IIOP (default) or JRMP
       •   Security available: MBean authentication and/or SSL
       •   Use -Xhealthcenter:level=off to only start collection when the first client
           connects (pseudo late attach). Preferences > Subsystem Enablement to turn
           off.
     – Headless (-Xhealthcenter:level=headless)
     – Late Attach (into either of the above two modes)
 Logging
     – Log file created in the temp directory named healthcenter.$PID.log
 The agent does use ~50MB native memory in the JVM
10                                                                         © 2012 IBM Corporation
Dynamically Starting the Agent
 The Java Late Attach API allows the injection of a native
     or Java library into a running JVM without restarting it.
 Late attach is available on these IBM JVM levels:
     – Java 5 >= SR10 (disabled by default) [WAS >= 6.1.0.27]
     – Java 6 >= SR6 (enabled by default on non-z/OS platforms) [WAS
       >= 7.0.0.7]
     – Java 6 R26 [WAS 8] (enabled by default)
     – Java 7 (enabled by default)
 Late attached can be controlled with the generic JVM
     argument -Dcom.ibm.tools.attach.enable=[yes|no]


11                                                          © 2012 IBM Corporation
Dynamically Starting the Agent
 If the JVM supports late attach and it is enabled:
     – $ cd <WAS>/java/jre/lib/ext
     – List available late attach JVMs:
       • $ ../../bin/java -jar healthcenter.jar
     – Attach to a particular JVM:
       • $ ../../bin/java -jar healthcenter.jar ID=$PID
          -Dcom.ibm.java.diagnostics.healthcenter.data.collection.level=headless
     – It's currently not possible to disable headless mode with late attach.




12                                                                        © 2012 IBM Corporation
Socket Mode
 Generally problematic in production environments
     because of firewalls; however, here are a few things to
     note about socket mode:
     – If client X connects, they get all data up to that point that fit in
       memory buffers. If X disconnects and a new client Y connects, the
       data that X saw will not be available, only new data since then.
      • Methods classloaded before client Y may not show for Y.
     – In memory buffers have a limited size, so some data may be lost.
     – Export collected data into an HCD file by clicking File > Save Data
     – Client refreshes every 10 seconds
     – Supports requesting java dump, heap dump, and system dump
     – The agent uses a random port for ORB which needs firewall hole:
       -Dcom.ibm.java.diagnostics.healthcenter.agent.iiop.port=N
13                                                                © 2012 IBM Corporation
Headless Mode
 Usually the best way to use health center in production
     environments, but also usually requires updating the
     shipped agent.
 Does not open a socket but instead writes agent data to
     the local file system:
     – Directory controlled with
       -Dcom.ibm.java.diagnostics.healthcenter.headless.output.directory
       =DIR
     – Defaults to the WAS profile directory




14                                                           © 2012 IBM Corporation
Headless Mode
 Files the agent writes to while the JVM is running:
     – EnvironmentSource$PID*
     – JLASource$PID*
     – MemoryCountersSource$PID*
     – MemorySource$PID*
     – MethodDictionarySource$PID*
     – TRACESubscriberSource$PID*
 When the JVM stops, the agent ZIPs these files into a file in the
     output directory called healthcenter$PID.hcd. The files (other
     than the HCD) are then deleted.
     – These files are compressed well into the HCD (up to 75%).
 If the JVM crashes, manually ZIP the files into an HCD
15                                                           © 2012 IBM Corporation
Headless Mode
 I've run HC in headless mode in massive production
     systems with little overhead; however, the agent files can
     be quite large – the largest I've seen are a few GB per
     hour.
 Each output file has a maximum size of 2GB
 Recent versions of the agent have options to roll over the
     files:
     – -Dcom.ibm.java.diagnostics.healthcenter.headless.files.max.size
       =BYTES
     – -Dcom.ibm.java.diagnostics.healthcenter.headless.files.to.keep=N
      • Use 0 to keep all of them



16                                                           © 2012 IBM Corporation
Headless Mode
 To do rollover, the agent appends _N to each file where N is
     the iteration number. When one of the files reaches 2GB or
     the value of max.size (usually the TRACESubscriberSource
     which has the profiling data), the agent will create an
     healthcenter$PID_N.hcd file and then start _N+1 files.
 When max.size files is hit, the agent will delete the oldest
     ones.
 If headless mode is not supported by agent version, error:
     – SEVERE: Health Center agent failed to start.
       java.lang.IllegalArgumentException: No enum const class
       com.ibm.java.diagnostics.healthcenter.agent.dataproviders.DataC
       ollectionLevel.HEADLESS
     – Check both healthcenter.log and native_std*.log
17                                                          © 2012 IBM Corporation
Headless Mode
 The volume of data will be a function of many variables:
     – The length of time of the data collection
     – The average number of active threads
     – The average stack depth of said threads
     – The available number of processors
     – The number of method calls per request
     – Etc.
 The best approach is to run a stress test in a stress test
     environment to gauge how much space will be needed.



18                                                   © 2012 IBM Corporation
Client: Installing
 Four ways to install the client:
     – IBM Support Assistant > Tools Addon > JVM-based Tools
      • IBM Monitoring and Diagnostic Tools for Java - Health Center
     – Extend an existing Eclipse installation
      • Add an update site:
        http://download.boulder.ibm.com/ibmdl/pub/software/isa/isa410/production/
      • Select the same tool as above
     – Internal, IBM-only standalone build:
      • http://chevalier.hursley.ibm.com/javatb/downloads/healthcenter/healthcenterdownloads.html
        – Also a development build page. Internal package development builds include additional
           debug, so external package development builds should be used.
     – Internal, IBM-only Eclipse update site:
      • http://chevalier.hursley.ibm.com/javatb/isaupdatesite/hcfeature/



19                                                                                   © 2012 IBM Corporation
Loading an HCD in the Client
 The file must have a .zip or .hcd extension
 Start the client
 Click Cancel on the dialog that pops up asking to connect
     to an existing JVM
 Click File > Load Data




20                                                © 2012 IBM Corporation
Client Timeline
 When zooming in on any of the timelines, all of the data
     views update to just that time range
 This is great for comparing two time ranges, or focusing
     in on important time ranges (for example, removing the
     startup time so that it does not skew the statistics)
 However, the time ranges are specified in time from the
     start of the JVM instead of in absolute terms.
 The healthcenter.log can be used to approximate when
     the JVM started (when the agent reports it started).




21                                                     © 2012 IBM Corporation
Client Timeline
 To get an exact start time:
     – Load the HCD file
     – File > Export JVM Trace...
     – java com.ibm.jvm.format.TraceFormat hcd.trc
     – In the resulting .fmt file, search for:
       • JVM started     : 20:11:29.084000000
     – This is in the GMT/UTC time zone.
     – Normally, it is important to use the same JVM version and get the
       J9TraceFormat.dat file from the customer, but in this case we just
       want the timestamp which does not depend on that info, so use
       any IBM JVM.


22                                                             © 2012 IBM Corporation
Client Summary
 Summary view highlights warnings




23                                   © 2012 IBM Corporation
Profiling




 Self (%): The percentage of samples taken while a particular method was being run at the top of the
     stack. This value is a good indicator of how expensive a method is...
     – This is roughly the CPU % usage of the Java CPU % usage. So, gather OS CPU stats with HC.
     – For example, if Java CPU% was 50% (let's say of all CPUs), and a method is 50% in Self, then
       that method used roughly 25% of all CPUs.

 Tree (%): The percentage of samples taken while a particular method was anywhere in the call
     stack. This value shows the percentage of time that this method, and methods it called
     (descendants), were being processed. This value gives a good guide to the areas of your application
     where most processing time is spent.

 Samples: Number of samples while a particular method was being run at the top of the stack.
24                                                                                      © 2012 IBM Corporation
Profiling




 This is a simple case where, if we sort by Self (%), MutableBigInteger.divideOneWord is at
     the top of sampled stacks almost half the time.

 Sorting by Tree % is sometimes useful, but WAS tends to have big stacks, so a lot of methods
     will be in a lot of the stacks. There are some heuristics here such as skipping the “common,
     do-nothing” methods, but this is an art more than a science.




25                                                                                  © 2012 IBM Corporation
Profiling




 Select the first row and the Invocation paths view will show who is calling this method.
 Each row contains a percentage of how many times that method called the above method out
     of all callers of that method.

 DoComplicatedWork.doWork is the primary caller, and this shows itself in the samples too.

26                                                                                 © 2012 IBM Corporation
Profiling




 The percentages are not cumulative. For example, in the above, of all calls to the first row, the
     second row (Branch.match) was 73.8% of them. The third row called the second row 73.2% of
     the time. So the third row was the indirect caller of the first row .738*.732=54% of the time.




27                                                                                  © 2012 IBM Corporation
Profiling




 Some JVM versions and service releases, and some agent versions, may not be able to
     determine the method name and you'll see a hexadecimal address. This may also occur with
     methods that were used before the agent started (and the JVM version didn't have the
     capability to tell the agent after the fact). Two methods (pun!) to find the method:
     – Take a system dump and use DTFJ to find the method at that address.
     – Infer the method (or its general area) by looking at the invocation paths and called
       methods. Above, we can infer that method is in LTPA/security.

28                                                                                   © 2012 IBM Corporation
Profiling
 Breaking down
     “overall” profiles
     – Sort by Tree (%)
     – Select the first row which
       is usually
       ThreadPool$Worker.run()
     – Go to the Called Methods
       view
     – Follow down the
       highest percentages
       (may split)




29                                  © 2012 IBM Corporation
Profiling
 If garbage collection analysis highlights System.gc calls,
     profiling view may have caught some of these and will
     show who called System.gc under Invocation Paths (Filter
     methods to System.gc)
 This is a statistical profiler, sampling the call stacks
     periodically rather than recording every method that is
     run. Methods that do not run often, or methods that run
     quickly, might not show in the profile list. Methods
     compiled by the Just-In-Time (JIT) compiler are profiled,
     but methods that have been inlined are not.
 Methods may be inlined at runtime! This will cause them
     to “drop down” in the profiling view and the calling
     method picks up the samples.
30                                                     © 2012 IBM Corporation
Profiling
 To get more details on particular methods:




 Then restart the JVM with those generic JVM arguments
     – ‑Xtrace:maximal=mt,methods={"java/math/MutableBigInteger.divid
       eOneWord"}


31                                                         © 2012 IBM Corporation
Profiling
 With method trace enabled




32                            © 2012 IBM Corporation
Low Mode
 -Xhealthcenter:level=low disables method profiling since this has the
     highest overhead and creates the most data. This would be useful if you
     wanted something else from health center (e.g. garbage collection, native
     memory, etc.) with less overhead.
 Low cannot be combined with headless (e.g.
     -Xhealthcenter:level=low,level=headless), so the way to do it is to use
     headless mode and then:
     – In jre/lib/ext there is a file called healthcenter.jar. If you unpack that you
       will find a file called TRACESourceConfiguration.properties and this is
       what defines which data is switched on by Trace. When we run in low
       mode, we turn off one of the profiling trace points. You can do this
       manually by editing this file and finding the entry "j9jit.16=on" and then
       changing it to "j9jit.16=off". If you repackage the jar up you should find
       that the amount of trace generated is a lot less (but you won't get
       method profiling).

33                                                                        © 2012 IBM Corporation
Profiling Theory
 The Health Center profiler has the same limitations as other sampling profilers; it
     can't distinguish between a method which is invoked once but takes a really long
     time to run, and a method which is very quick but invoked frequently. It won't report
     methods which take a long time where the majority of that time is spent waiting,
     because it only reports methods which are using CPU. For a class which loops
     with sleep statements in each loop, Health Center won't report the looping method
     because that method isn't actually using any CPU, even though it has a long
     elapsed time.
 These limitations are the same for all sampling profilers. The alternative is to use a
     tracing profiler, which captures method entry and exit. It will report elapsed time in
     methods, but it won't report CPU utilisation. This has its own set of disadvantages,
     since it could suggest optimising a method where most time is actually spent
     waiting on an external input. Tracing profilers in general also have far higher
     overhead than sampling profilers. In order to keep the overhead manageable, they
     tend to focus on just some sections of the codebase, and will only report elapsed
     time for certain methods or classes. This is risky, since it requires the performance
     analyst to guess which areas are causing performance problems before doing the
     performance analysis - serious bottlenecks could be missed entirely.

34                                                                            © 2012 IBM Corporation
Large Object Allocations
 Properties:
     – -Dcom.ibm.java.diagnostics.healthcenter.allocation.threshold.low=BYTES
     – -Dcom.ibm.java.diagnostics.healthcenter.allocation.threshold.high=BYTES

 Example:
     – -Dcom.ibm.java.diagnostics.healthcenter.allocation.threshold.low=1048576

 Under
     Garbage
     Collection >
     Object
     Allocations




35                                                                      © 2012 IBM Corporation
Locking




36        © 2012 IBM Corporation
Locking
 Gets: The total number of times the lock has been taken while it was inflated.
 Slow: The total number of non-recursive lock acquires for which the requesting thread had to wait for
     the lock because it was already owned by another thread.

 % miss: The percentage of the total Gets, or acquires, for which the thread trying to enter the lock on
     the synchronized code had to block until it could take the lock. % miss = (Slow / Gets) * 100
     – A high % miss shows that frequent contention occurs on the synchronized resource protected by
       the lock. This contention might be preventing the Java application from scaling further.
     – If a lock has a high % miss value, look at the average hold time and % util. If % util and average
       hold time are both high, you might need to reduce the amount of work done while the lock is held.
       If % util is high but the average hold time is low, you might need to make the resource protected
       by the lock more granular to separate the lock into multiple locks.

 Recursive: The total number of recursive acquires. A recursive acquire occurs when the requesting
     thread already owns the monitor.

 % util: The amount of time the lock was held, divided by the amount of time the output was taken
     over.

 Average hold time: The average amount of time the lock was held, or owned, by a thread. For
     example, the amount of time spent in the synchronized block, measured in processor clock ticks.

37                                                                                         © 2012 IBM Corporation
Locking
 The height of the bars represents the slow lock count and is relative
     to all the columns in the graph. A slow count occurs when the
     requested monitor is already owned by another thread and the
     requesting thread is blocked.
 The color of each bar is based on the value of the % miss column in
     the table. The gradient moves from red (100%), through yellow
     (50%), to green (0%). A red bar indicates that the thread blocks
     every time that the monitor is requested. A green bar indicates a
     thread that never blocks.
 Show internal JVM monitor lock information:


 If a lock is held while a garbage collection runs, this time is removed
     from the statistics of that lock.
38                                                             © 2012 IBM Corporation
Lock Name
 Lock name of the form:
     – [00007F418A0265E0] java/lang/Object@0000000004A2E408
       (Object)
 The number in brackets is the object address. Use a
     system dump to find who references the object.
 For older versions, you can look up using the object ID
     (@...) using a system dump, IEMA and IBM Extensions >
     Utilities > Find Object by Identifier




39                                                    © 2012 IBM Corporation
Garbage Collection




40                   © 2012 IBM Corporation
Environment




41            © 2012 IBM Corporation
Classes




42        © 2012 IBM Corporation
I/O Files Open




43               © 2012 IBM Corporation
Native Memory




44              © 2012 IBM Corporation
Native Memory - Breakdown
 Select Process Virtual Memory, then click breakdown




45                                               © 2012 IBM Corporation
Threads




46        © 2012 IBM Corporation
Getting Help
 Java Tools Email: javatool@uk.ibm.com
 Public Forum:
     http://www.ibm.com/developerworks/forums/forum.jspa?forumID=1461




47                                                              © 2012 IBM Corporation
Conclusion
 In summary, IBM Java Health Center is an extremely
     powerful tool which has a very low-overhead sampling
     profiler (among other features) and can be used on recent
     versions of WAS (>= 6.1.0.27 and >= 7.0.0.5) to determine
     the root cause of performance issues.
     – In general, recommend the headless mode to customers, which
       does involve ensuring the latest agent binaries are installed.




48                                                           © 2012 IBM Corporation
Appendix




49              © 2012 IBM Corporation
MustGather
 Even if running a very recent JVM, upgrade the Health Center agent and stop/start the JVM:
     – Download: http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/installingagent.html
     – cd <WAS>/java/
     – ./bin/jar xvf $FILE.zip

 If running WAS >= 7.0.0.7 on a non/z-OS platform, you may enable health center with late attach:
     – cd <WAS>/java/bin
     – ./java -jar ../jre/lib/ext/healthcenter.jar ID=$PID
       -Dcom.ibm.java.diagnostics.healthcenter.data.collection.level=headless
       -Dcom.ibm.java.diagnostics.healthcenter.headless.files.max.size=268435456
       -Dcom.ibm.java.diagnostics.healthcenter.headless.files.to.keep=8

 Otherwise, restart the JVM with the following generic JVM arguments:
     – -Xhealthcenter:level=headless -Dcom.ibm.java.diagnostics.healthcenter.headless.files.max.size=268435456
       -Dcom.ibm.java.diagnostics.healthcenter.headless.files.to.keep=8

 Start the WAIT data collector: https://wait.researchlabs.ibm.com/submit/dataCollector.html
 Reproduce the problem, stop the JVM(s) completely, stop the WAIT collector, upload *.hcd, WAS
     logs, <TEMP>/healthcenter.*.log, and waitData


50                                                                                                                            © 2012 IBM Corporation
Example: Socket Read
 Server socket that just waits:
 import java.io.*;
 import java.net.*;
 public class SocketDoNothing {
                   public static void main(String[] args) {
                                     try {
                                                      System.out.println("SocketDoNothing started");
                                                      int port = 23456;
                                                      ServerSocket serverSocket = new ServerSocket(port);
                                                      Socket socket = serverSocket.accept();
                                                      InputStream inputFromClient = socket.getInputStream();
                                                      OutputStream os = socket.getOutputStream();
                                                      byte b = (byte) inputFromClient.read();
                                                      while (b != -1) {
                                                                        System.out.println("Received byte = 0x" + Integer.toString(b, 16));
                                                                        switch (b) {
                                                                        case 1:
                                                                                         Thread.sleep(60000);
                                                                                         break;
                                                                        }
                                                                        os.write(1);
                                                                        b = (byte) inputFromClient.read();
                                                      }
                                                      os.close();
                                                      inputFromClient.close();
                                                      socket.close();
                                                      serverSocket.close();
                                     } catch (Throwable t) {
                                                      System.err.println("Error: " + t.getLocalizedMessage());
                                                      t.printStackTrace();
                                     }
                   }
 }

51                                                                                                                                       © 2012 IBM Corporation
Example: Socket Read
 Client with Health Center
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 public class HighWaiting {
               public static void main(String... args) {
                              try {
                                            System.out.println("HighWaiting started");
                                           Socket socket = new Socket("localhost", 23456);
                                           OutputStream os = socket.getOutputStream();
                                           InputStream is = socket.getInputStream();
                                           os.write(1);
                                           is.read();
                                           os.write(-1);
                                           is.close();
                                           os.close();
                                           socket.close();
                                           System.out.println("HighWaiting done");
                             } catch (Throwable t) {
                                          System.err.println("Error: " + t.getLocalizedMessage());
                                          t.printStackTrace();
                             }
               }
 }

52                                                                                                   © 2012 IBM Corporation
Example: Socket read results
 HighWaiting barely shows up in the profiling data




53                                                © 2012 IBM Corporation

More Related Content

PDF
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
PPTX
2. OS vs. VMM
PDF
ALSF13: Xen on ARM - Virtualization for the Automotive Industry - Stefano Sta...
PDF
Alexei Vladishev - Zabbix - Monitoring Solution for Everyone
ODP
Q4.11: Porting Android to new Platforms
PDF
Kernel_Crash_Dump_Analysis
PDF
Maven et industrialisation du logiciel
PPTX
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
2. OS vs. VMM
ALSF13: Xen on ARM - Virtualization for the Automotive Industry - Stefano Sta...
Alexei Vladishev - Zabbix - Monitoring Solution for Everyone
Q4.11: Porting Android to new Platforms
Kernel_Crash_Dump_Analysis
Maven et industrialisation du logiciel
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...

What's hot (20)

PDF
Node.JS Interview Questions .pdf
PDF
Node JS Interview Question PDF By ScholarHat
PDF
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
PDF
Hacking Android OS
PDF
Upgrade to IBM z/OS V2.5 technical actions
PDF
Ansible tips & tricks
PDF
Android Internals
PDF
IBM WebSphere application server
PDF
[WhaTap DevOps Day] 세션 1 : Observability Practice on AWS
PPTX
[오픈소스컨설팅]인프라 자동화 도구 Chef
PDF
Implementing Lightweight Networking
PPT
Power systems virtualization with power kvm
PDF
ELC21: VM-to-VM Communication Mechanisms for Embedded
PDF
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
PDF
Zabbix
PPTX
JavaScript Core fundamentals - Learn JavaScript Here
PDF
Xen on ARM for embedded and IoT: from secure containers to dom0less systems
PDF
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
PDF
The Open vSwitch and OVN Projects
Node.JS Interview Questions .pdf
Node JS Interview Question PDF By ScholarHat
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
Hacking Android OS
Upgrade to IBM z/OS V2.5 technical actions
Ansible tips & tricks
Android Internals
IBM WebSphere application server
[WhaTap DevOps Day] 세션 1 : Observability Practice on AWS
[오픈소스컨설팅]인프라 자동화 도구 Chef
Implementing Lightweight Networking
Power systems virtualization with power kvm
ELC21: VM-to-VM Communication Mechanisms for Embedded
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
Zabbix
JavaScript Core fundamentals - Learn JavaScript Here
Xen on ARM for embedded and IoT: from secure containers to dom0less systems
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
The Open vSwitch and OVN Projects
Ad

Viewers also liked (20)

PDF
IBM Monitoring and Diagnostics Tools - Health Center 3.0.2
PDF
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
PDF
IBM Monitoring and Diagnostic Tools - GCMV 2.8
PPT
Greater Prince William Community Health Center: Advocacy Techniques, Success ...
PPT
Overhauling Health Center Operations: Project RevUp 101
PPT
IU Health Center PHR Project
PPT
Community Health Centers and National Advocacy
PPT
Stop complaining and start advocating advocacy in action.
PPTX
Advocacy in Medicine
PPTX
Wiosenny festyn w Turgutlu
PPTX
Comenius prezentacja nr 1 angielska
PPTX
Advocacy for Health Equity
PDF
InterConnect2016 Monitoring Nodejs
PPT
مركز الرياض الترفيهي
PPT
Nursery Management and Certification System
PPTX
Health promotion (2)
PPTX
FQHC 101 What is a Community Health Center?
PDF
Focus e commerce-2011-web
PDF
Why launching a venture in France
PDF
hadoop事例紹介
IBM Monitoring and Diagnostics Tools - Health Center 3.0.2
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
IBM Monitoring and Diagnostic Tools - GCMV 2.8
Greater Prince William Community Health Center: Advocacy Techniques, Success ...
Overhauling Health Center Operations: Project RevUp 101
IU Health Center PHR Project
Community Health Centers and National Advocacy
Stop complaining and start advocating advocacy in action.
Advocacy in Medicine
Wiosenny festyn w Turgutlu
Comenius prezentacja nr 1 angielska
Advocacy for Health Equity
InterConnect2016 Monitoring Nodejs
مركز الرياض الترفيهي
Nursery Management and Certification System
Health promotion (2)
FQHC 101 What is a Community Health Center?
Focus e commerce-2011-web
Why launching a venture in France
hadoop事例紹介
Ad

Similar to IBM Health Center Details (20)

PPT
Share seattle health_center
PDF
Websphere doctor - your guide to diagnose issues
PDF
Java on IBM z15
PDF
Social Conndections VI -- Debugging IBM Connections During Install And Operation
PDF
WebSphere Technical University: Introduction to the Java Diagnostic Tools
PDF
Java one2016
PDF
Introduction to the IBM Java Tools
PDF
Impact2014: Introduction to the IBM Java Tools
PDF
Iib v10 performance problem determination examples
PDF
Java on zSystems zOS
PDF
Impact2014 session # 1523 performance optimization using ibm java on z and w...
PDF
Virtualization aware Java VM
PPT
HL7 DFDL with WebSphere Message Broker
PDF
Reasons to love IBM Java and Websphere Application Server on z system
PDF
Reasons to Love IBM Java and WebSphere Application Server on z System
PDF
NZS-4409 - Enterprise Java Monitoring on zOS Discover, Alert, Optimize
PDF
Java on the Mainframe
PDF
JavaOne 2014: Java Debugging
PPT
Java on z overview 20161107
ODT
Healthcheck 07 application
Share seattle health_center
Websphere doctor - your guide to diagnose issues
Java on IBM z15
Social Conndections VI -- Debugging IBM Connections During Install And Operation
WebSphere Technical University: Introduction to the Java Diagnostic Tools
Java one2016
Introduction to the IBM Java Tools
Impact2014: Introduction to the IBM Java Tools
Iib v10 performance problem determination examples
Java on zSystems zOS
Impact2014 session # 1523 performance optimization using ibm java on z and w...
Virtualization aware Java VM
HL7 DFDL with WebSphere Message Broker
Reasons to love IBM Java and Websphere Application Server on z system
Reasons to Love IBM Java and WebSphere Application Server on z System
NZS-4409 - Enterprise Java Monitoring on zOS Discover, Alert, Optimize
Java on the Mainframe
JavaOne 2014: Java Debugging
Java on z overview 20161107
Healthcheck 07 application

More from Rohit Kelapure (20)

PDF
API First or Events First: Is it a Binary Choice?
PDF
External should that be a microservice
PDF
Should That Be a Microservice ?
PPTX
Travelers 360 degree health assessment of microservices on the pivotal platform
PDF
SpringOne Platform 2018 Recap in 5 minutes
PDF
Migrate Heroku & OpenShift Applications to IBM BlueMix
PDF
Liberty Buildpack: Designed for Extension - Integrating your services in Blue...
PDF
A Deep Dive into the Liberty Buildpack on IBM BlueMix
PDF
Liberty dynacache ffw_iea_ste
PDF
1812 icap-v1.3 0430
PDF
Dynacache in WebSphere Portal Server
PPT
Classloader leak detection in websphere application server
PPTX
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
PDF
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
PPTX
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
DOC
Web sphere application server performance tuning workshop
PPT
Performance tuningtoolkitintroduction
PPTX
Java EE vs Spring Framework
PPTX
Debugging java deployments_2
ODP
Caching technology comparison
API First or Events First: Is it a Binary Choice?
External should that be a microservice
Should That Be a Microservice ?
Travelers 360 degree health assessment of microservices on the pivotal platform
SpringOne Platform 2018 Recap in 5 minutes
Migrate Heroku & OpenShift Applications to IBM BlueMix
Liberty Buildpack: Designed for Extension - Integrating your services in Blue...
A Deep Dive into the Liberty Buildpack on IBM BlueMix
Liberty dynacache ffw_iea_ste
1812 icap-v1.3 0430
Dynacache in WebSphere Portal Server
Classloader leak detection in websphere application server
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Web sphere application server performance tuning workshop
Performance tuningtoolkitintroduction
Java EE vs Spring Framework
Debugging java deployments_2
Caching technology comparison

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Mushroom cultivation and it's methods.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Getting Started with Data Integration: FME Form 101
PPTX
1. Introduction to Computer Programming.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Unlocking AI with Model Context Protocol (MCP)
Assigned Numbers - 2025 - Bluetooth® Document
Mushroom cultivation and it's methods.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Univ-Connecticut-ChatGPT-Presentaion.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Getting Started with Data Integration: FME Form 101
1. Introduction to Computer Programming.pptx
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

IBM Health Center Details

  • 1. IBM Java Health Center Kevin Grigorenko (IBM WAS SWAT Team) [email protected] © 2012 IBM Corporation
  • 2. IBM Java Health Center  The IBM Java Health Center is a very low overhead tool that runs in the IBM JVM and provides information on method profiling, garbage collection, I/O, lock analysis, threads, native memory, and more.  Fully supported by the IBM Java Tools team through PMRs.  Important Links: – Product Page: http://www.ibm.com/developerworks/java/jdk/tools/healthcenter/ – Documentation: http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/introduction.html  Similar to HotSpot/Oracle's VisualVM and JRockit Mission Control  It runs with the IBM JVM (32- or 64-bit) on: AIX, Linux, Windows, and z/OS. 2 © 2012 IBM Corporation
  • 3. When to Use Health Center  Health Center is particularly good for deep dives into performance issues, high CPU and monitor contention.  It does not have the overall capabilities of monitoring products such as ITCAM.  The sampling profiler currently has lower overhead than monitoring products due to very tight coupling with IBM JVM internals and bypassing of JVMTI interfaces. – Overhead of sampling profiler usually as low as < 1% or 2% 3 © 2012 IBM Corporation
  • 4. Agent & Client  The Health Center Agent is a JVMTI native library that must be enabled (off by default) – Most often enabled using a generic JVM argument -Xhealthcenter or -Xhealthcenter:level=headless and restarting the JVM – Recent versions can be enabled dynamically using late attach – Two modes: 1) Connected to a client through a socket, 2) headless  The Health Center Client is an Eclipse-based GUI perspective which is used to analyze agent data – Two modes: 1) Connected to the agent through a socket, 2) load HCD file produced by the agent or exported from another client 4 © 2012 IBM Corporation
  • 5. Agent: Getting Started  The IBM JVM ships with Health Center: – …/java/jre/lib/$PLATFORM/libhealthcenter.so – …/java/jre/lib/ext/healthcenter.jar – …/java/jre/lib/healthcenter.properties – …/java/jre/bin/libhealthcenter.so  Health Center performance and functionality is affected by two things: 1) the version & service release of the JVM, and 2) the version of the agent – If practical, it's always best to update the agent because the agent is independent of the JVM and the latest will have bug fixes, additional collection, better command line options, etc. 5 © 2012 IBM Corporation
  • 6. Minimum JVM Version for Agent Use in Production  Platform requirements: – http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/platforms.html IBM Java Minimum Minimum WAS Owned Native Enable Allocation Version Service Release Release for use in Monitor Memory verbosegc Sampling for use in production Information Breakdown at runtime Production Java 5     SR10 WAS 6.1.0.27 SR5 WAS 7.0.0.5 Java 6         Java 626 Any WAS 8.0     Java 7 Any WAS 8.5 6 © 2012 IBM Corporation
  • 7. Checking the Installed Agent Version  Two ways to figure out the installed version: – Run java -version -Xhealthcenter • $ …/java/bin/java -version -Xhealthcenter – … Feb 14, 2012 11:06:56 AM com.ibm.java.diagnostics.healthcenter.agent.mbean.HCLaunchMBean startAgent INFO: Agent version "1.3.0.20101014" – Extract version.properties from …/java/jre/lib/ext/healthcenter.jar • $ jar xvf …/java/jre/lib/ext/healthcenter.jar version.properties • $ cat version.properties – jar.version=1.3.0.20101014 7 © 2012 IBM Corporation
  • 8. Getting the Latest Agent  Three ways to get the latest agent: – Health Center Documentation Page: http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/installingagent.html – From within IBM Support Assistant, click Help > Help Contents > … Health Center > … Installing the Health Center Agent – Internal, IBM-only builds: http://chevalier.hursley.ibm.com/javatb/downloads/healthcenter/healthcenterdownloads.html  The agent bitness (32- or 64-bit) should match the JVM bitness, not the operating system bitness. • For example, if it is a 32-bit JVM running on a 64-bit operating system, download the 32-bit agent. 8 © 2012 IBM Corporation
  • 9. Updating the Agent  Some customers are weary about updating the WAS installation files; however, the files being updated do not relate to non-Health Center functionality.  Consider backing up the existing agent files in case there are problems.  Procedure (for z/OS, see documentation) – Upload the ZIP file to <WAS>/java/$FILE.zip – Change directory to <WAS>/java/ and run the command: • ./bin/jar xvf $FILE.zip – Make sure to chown the updated files properly. – Error “in use” because you just tried running health center (e.g. checking the version) and on some operating systems, may persist unless all related Java processes are stopped. • If it still doesn't work, and the JVM is run by a non-root user, then try extracting the zip using the root user, and then chown to the non-root user. 9 © 2012 IBM Corporation
  • 10. Enabling the Agent  There are three modes: – Socket Communication (-Xhealthcenter) • By default opens port 1972 or the first available increment up to 2072 • Communication either in IIOP (default) or JRMP • Security available: MBean authentication and/or SSL • Use -Xhealthcenter:level=off to only start collection when the first client connects (pseudo late attach). Preferences > Subsystem Enablement to turn off. – Headless (-Xhealthcenter:level=headless) – Late Attach (into either of the above two modes)  Logging – Log file created in the temp directory named healthcenter.$PID.log  The agent does use ~50MB native memory in the JVM 10 © 2012 IBM Corporation
  • 11. Dynamically Starting the Agent  The Java Late Attach API allows the injection of a native or Java library into a running JVM without restarting it.  Late attach is available on these IBM JVM levels: – Java 5 >= SR10 (disabled by default) [WAS >= 6.1.0.27] – Java 6 >= SR6 (enabled by default on non-z/OS platforms) [WAS >= 7.0.0.7] – Java 6 R26 [WAS 8] (enabled by default) – Java 7 (enabled by default)  Late attached can be controlled with the generic JVM argument -Dcom.ibm.tools.attach.enable=[yes|no] 11 © 2012 IBM Corporation
  • 12. Dynamically Starting the Agent  If the JVM supports late attach and it is enabled: – $ cd <WAS>/java/jre/lib/ext – List available late attach JVMs: • $ ../../bin/java -jar healthcenter.jar – Attach to a particular JVM: • $ ../../bin/java -jar healthcenter.jar ID=$PID -Dcom.ibm.java.diagnostics.healthcenter.data.collection.level=headless – It's currently not possible to disable headless mode with late attach. 12 © 2012 IBM Corporation
  • 13. Socket Mode  Generally problematic in production environments because of firewalls; however, here are a few things to note about socket mode: – If client X connects, they get all data up to that point that fit in memory buffers. If X disconnects and a new client Y connects, the data that X saw will not be available, only new data since then. • Methods classloaded before client Y may not show for Y. – In memory buffers have a limited size, so some data may be lost. – Export collected data into an HCD file by clicking File > Save Data – Client refreshes every 10 seconds – Supports requesting java dump, heap dump, and system dump – The agent uses a random port for ORB which needs firewall hole: -Dcom.ibm.java.diagnostics.healthcenter.agent.iiop.port=N 13 © 2012 IBM Corporation
  • 14. Headless Mode  Usually the best way to use health center in production environments, but also usually requires updating the shipped agent.  Does not open a socket but instead writes agent data to the local file system: – Directory controlled with -Dcom.ibm.java.diagnostics.healthcenter.headless.output.directory =DIR – Defaults to the WAS profile directory 14 © 2012 IBM Corporation
  • 15. Headless Mode  Files the agent writes to while the JVM is running: – EnvironmentSource$PID* – JLASource$PID* – MemoryCountersSource$PID* – MemorySource$PID* – MethodDictionarySource$PID* – TRACESubscriberSource$PID*  When the JVM stops, the agent ZIPs these files into a file in the output directory called healthcenter$PID.hcd. The files (other than the HCD) are then deleted. – These files are compressed well into the HCD (up to 75%).  If the JVM crashes, manually ZIP the files into an HCD 15 © 2012 IBM Corporation
  • 16. Headless Mode  I've run HC in headless mode in massive production systems with little overhead; however, the agent files can be quite large – the largest I've seen are a few GB per hour.  Each output file has a maximum size of 2GB  Recent versions of the agent have options to roll over the files: – -Dcom.ibm.java.diagnostics.healthcenter.headless.files.max.size =BYTES – -Dcom.ibm.java.diagnostics.healthcenter.headless.files.to.keep=N • Use 0 to keep all of them 16 © 2012 IBM Corporation
  • 17. Headless Mode  To do rollover, the agent appends _N to each file where N is the iteration number. When one of the files reaches 2GB or the value of max.size (usually the TRACESubscriberSource which has the profiling data), the agent will create an healthcenter$PID_N.hcd file and then start _N+1 files.  When max.size files is hit, the agent will delete the oldest ones.  If headless mode is not supported by agent version, error: – SEVERE: Health Center agent failed to start. java.lang.IllegalArgumentException: No enum const class com.ibm.java.diagnostics.healthcenter.agent.dataproviders.DataC ollectionLevel.HEADLESS – Check both healthcenter.log and native_std*.log 17 © 2012 IBM Corporation
  • 18. Headless Mode  The volume of data will be a function of many variables: – The length of time of the data collection – The average number of active threads – The average stack depth of said threads – The available number of processors – The number of method calls per request – Etc.  The best approach is to run a stress test in a stress test environment to gauge how much space will be needed. 18 © 2012 IBM Corporation
  • 19. Client: Installing  Four ways to install the client: – IBM Support Assistant > Tools Addon > JVM-based Tools • IBM Monitoring and Diagnostic Tools for Java - Health Center – Extend an existing Eclipse installation • Add an update site: http://download.boulder.ibm.com/ibmdl/pub/software/isa/isa410/production/ • Select the same tool as above – Internal, IBM-only standalone build: • http://chevalier.hursley.ibm.com/javatb/downloads/healthcenter/healthcenterdownloads.html – Also a development build page. Internal package development builds include additional debug, so external package development builds should be used. – Internal, IBM-only Eclipse update site: • http://chevalier.hursley.ibm.com/javatb/isaupdatesite/hcfeature/ 19 © 2012 IBM Corporation
  • 20. Loading an HCD in the Client  The file must have a .zip or .hcd extension  Start the client  Click Cancel on the dialog that pops up asking to connect to an existing JVM  Click File > Load Data 20 © 2012 IBM Corporation
  • 21. Client Timeline  When zooming in on any of the timelines, all of the data views update to just that time range  This is great for comparing two time ranges, or focusing in on important time ranges (for example, removing the startup time so that it does not skew the statistics)  However, the time ranges are specified in time from the start of the JVM instead of in absolute terms.  The healthcenter.log can be used to approximate when the JVM started (when the agent reports it started). 21 © 2012 IBM Corporation
  • 22. Client Timeline  To get an exact start time: – Load the HCD file – File > Export JVM Trace... – java com.ibm.jvm.format.TraceFormat hcd.trc – In the resulting .fmt file, search for: • JVM started : 20:11:29.084000000 – This is in the GMT/UTC time zone. – Normally, it is important to use the same JVM version and get the J9TraceFormat.dat file from the customer, but in this case we just want the timestamp which does not depend on that info, so use any IBM JVM. 22 © 2012 IBM Corporation
  • 23. Client Summary  Summary view highlights warnings 23 © 2012 IBM Corporation
  • 24. Profiling  Self (%): The percentage of samples taken while a particular method was being run at the top of the stack. This value is a good indicator of how expensive a method is... – This is roughly the CPU % usage of the Java CPU % usage. So, gather OS CPU stats with HC. – For example, if Java CPU% was 50% (let's say of all CPUs), and a method is 50% in Self, then that method used roughly 25% of all CPUs.  Tree (%): The percentage of samples taken while a particular method was anywhere in the call stack. This value shows the percentage of time that this method, and methods it called (descendants), were being processed. This value gives a good guide to the areas of your application where most processing time is spent.  Samples: Number of samples while a particular method was being run at the top of the stack. 24 © 2012 IBM Corporation
  • 25. Profiling  This is a simple case where, if we sort by Self (%), MutableBigInteger.divideOneWord is at the top of sampled stacks almost half the time.  Sorting by Tree % is sometimes useful, but WAS tends to have big stacks, so a lot of methods will be in a lot of the stacks. There are some heuristics here such as skipping the “common, do-nothing” methods, but this is an art more than a science. 25 © 2012 IBM Corporation
  • 26. Profiling  Select the first row and the Invocation paths view will show who is calling this method.  Each row contains a percentage of how many times that method called the above method out of all callers of that method.  DoComplicatedWork.doWork is the primary caller, and this shows itself in the samples too. 26 © 2012 IBM Corporation
  • 27. Profiling  The percentages are not cumulative. For example, in the above, of all calls to the first row, the second row (Branch.match) was 73.8% of them. The third row called the second row 73.2% of the time. So the third row was the indirect caller of the first row .738*.732=54% of the time. 27 © 2012 IBM Corporation
  • 28. Profiling  Some JVM versions and service releases, and some agent versions, may not be able to determine the method name and you'll see a hexadecimal address. This may also occur with methods that were used before the agent started (and the JVM version didn't have the capability to tell the agent after the fact). Two methods (pun!) to find the method: – Take a system dump and use DTFJ to find the method at that address. – Infer the method (or its general area) by looking at the invocation paths and called methods. Above, we can infer that method is in LTPA/security. 28 © 2012 IBM Corporation
  • 29. Profiling  Breaking down “overall” profiles – Sort by Tree (%) – Select the first row which is usually ThreadPool$Worker.run() – Go to the Called Methods view – Follow down the highest percentages (may split) 29 © 2012 IBM Corporation
  • 30. Profiling  If garbage collection analysis highlights System.gc calls, profiling view may have caught some of these and will show who called System.gc under Invocation Paths (Filter methods to System.gc)  This is a statistical profiler, sampling the call stacks periodically rather than recording every method that is run. Methods that do not run often, or methods that run quickly, might not show in the profile list. Methods compiled by the Just-In-Time (JIT) compiler are profiled, but methods that have been inlined are not.  Methods may be inlined at runtime! This will cause them to “drop down” in the profiling view and the calling method picks up the samples. 30 © 2012 IBM Corporation
  • 31. Profiling  To get more details on particular methods:  Then restart the JVM with those generic JVM arguments – ‑Xtrace:maximal=mt,methods={"java/math/MutableBigInteger.divid eOneWord"} 31 © 2012 IBM Corporation
  • 32. Profiling  With method trace enabled 32 © 2012 IBM Corporation
  • 33. Low Mode  -Xhealthcenter:level=low disables method profiling since this has the highest overhead and creates the most data. This would be useful if you wanted something else from health center (e.g. garbage collection, native memory, etc.) with less overhead.  Low cannot be combined with headless (e.g. -Xhealthcenter:level=low,level=headless), so the way to do it is to use headless mode and then: – In jre/lib/ext there is a file called healthcenter.jar. If you unpack that you will find a file called TRACESourceConfiguration.properties and this is what defines which data is switched on by Trace. When we run in low mode, we turn off one of the profiling trace points. You can do this manually by editing this file and finding the entry "j9jit.16=on" and then changing it to "j9jit.16=off". If you repackage the jar up you should find that the amount of trace generated is a lot less (but you won't get method profiling). 33 © 2012 IBM Corporation
  • 34. Profiling Theory  The Health Center profiler has the same limitations as other sampling profilers; it can't distinguish between a method which is invoked once but takes a really long time to run, and a method which is very quick but invoked frequently. It won't report methods which take a long time where the majority of that time is spent waiting, because it only reports methods which are using CPU. For a class which loops with sleep statements in each loop, Health Center won't report the looping method because that method isn't actually using any CPU, even though it has a long elapsed time.  These limitations are the same for all sampling profilers. The alternative is to use a tracing profiler, which captures method entry and exit. It will report elapsed time in methods, but it won't report CPU utilisation. This has its own set of disadvantages, since it could suggest optimising a method where most time is actually spent waiting on an external input. Tracing profilers in general also have far higher overhead than sampling profilers. In order to keep the overhead manageable, they tend to focus on just some sections of the codebase, and will only report elapsed time for certain methods or classes. This is risky, since it requires the performance analyst to guess which areas are causing performance problems before doing the performance analysis - serious bottlenecks could be missed entirely. 34 © 2012 IBM Corporation
  • 35. Large Object Allocations  Properties: – -Dcom.ibm.java.diagnostics.healthcenter.allocation.threshold.low=BYTES – -Dcom.ibm.java.diagnostics.healthcenter.allocation.threshold.high=BYTES  Example: – -Dcom.ibm.java.diagnostics.healthcenter.allocation.threshold.low=1048576  Under Garbage Collection > Object Allocations 35 © 2012 IBM Corporation
  • 36. Locking 36 © 2012 IBM Corporation
  • 37. Locking  Gets: The total number of times the lock has been taken while it was inflated.  Slow: The total number of non-recursive lock acquires for which the requesting thread had to wait for the lock because it was already owned by another thread.  % miss: The percentage of the total Gets, or acquires, for which the thread trying to enter the lock on the synchronized code had to block until it could take the lock. % miss = (Slow / Gets) * 100 – A high % miss shows that frequent contention occurs on the synchronized resource protected by the lock. This contention might be preventing the Java application from scaling further. – If a lock has a high % miss value, look at the average hold time and % util. If % util and average hold time are both high, you might need to reduce the amount of work done while the lock is held. If % util is high but the average hold time is low, you might need to make the resource protected by the lock more granular to separate the lock into multiple locks.  Recursive: The total number of recursive acquires. A recursive acquire occurs when the requesting thread already owns the monitor.  % util: The amount of time the lock was held, divided by the amount of time the output was taken over.  Average hold time: The average amount of time the lock was held, or owned, by a thread. For example, the amount of time spent in the synchronized block, measured in processor clock ticks. 37 © 2012 IBM Corporation
  • 38. Locking  The height of the bars represents the slow lock count and is relative to all the columns in the graph. A slow count occurs when the requested monitor is already owned by another thread and the requesting thread is blocked.  The color of each bar is based on the value of the % miss column in the table. The gradient moves from red (100%), through yellow (50%), to green (0%). A red bar indicates that the thread blocks every time that the monitor is requested. A green bar indicates a thread that never blocks.  Show internal JVM monitor lock information:  If a lock is held while a garbage collection runs, this time is removed from the statistics of that lock. 38 © 2012 IBM Corporation
  • 39. Lock Name  Lock name of the form: – [00007F418A0265E0] java/lang/Object@0000000004A2E408 (Object)  The number in brackets is the object address. Use a system dump to find who references the object.  For older versions, you can look up using the object ID (@...) using a system dump, IEMA and IBM Extensions > Utilities > Find Object by Identifier 39 © 2012 IBM Corporation
  • 40. Garbage Collection 40 © 2012 IBM Corporation
  • 41. Environment 41 © 2012 IBM Corporation
  • 42. Classes 42 © 2012 IBM Corporation
  • 43. I/O Files Open 43 © 2012 IBM Corporation
  • 44. Native Memory 44 © 2012 IBM Corporation
  • 45. Native Memory - Breakdown  Select Process Virtual Memory, then click breakdown 45 © 2012 IBM Corporation
  • 46. Threads 46 © 2012 IBM Corporation
  • 47. Getting Help  Java Tools Email: [email protected]  Public Forum: http://www.ibm.com/developerworks/forums/forum.jspa?forumID=1461 47 © 2012 IBM Corporation
  • 48. Conclusion  In summary, IBM Java Health Center is an extremely powerful tool which has a very low-overhead sampling profiler (among other features) and can be used on recent versions of WAS (>= 6.1.0.27 and >= 7.0.0.5) to determine the root cause of performance issues. – In general, recommend the headless mode to customers, which does involve ensuring the latest agent binaries are installed. 48 © 2012 IBM Corporation
  • 49. Appendix 49 © 2012 IBM Corporation
  • 50. MustGather  Even if running a very recent JVM, upgrade the Health Center agent and stop/start the JVM: – Download: http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/installingagent.html – cd <WAS>/java/ – ./bin/jar xvf $FILE.zip  If running WAS >= 7.0.0.7 on a non/z-OS platform, you may enable health center with late attach: – cd <WAS>/java/bin – ./java -jar ../jre/lib/ext/healthcenter.jar ID=$PID -Dcom.ibm.java.diagnostics.healthcenter.data.collection.level=headless -Dcom.ibm.java.diagnostics.healthcenter.headless.files.max.size=268435456 -Dcom.ibm.java.diagnostics.healthcenter.headless.files.to.keep=8  Otherwise, restart the JVM with the following generic JVM arguments: – -Xhealthcenter:level=headless -Dcom.ibm.java.diagnostics.healthcenter.headless.files.max.size=268435456 -Dcom.ibm.java.diagnostics.healthcenter.headless.files.to.keep=8  Start the WAIT data collector: https://wait.researchlabs.ibm.com/submit/dataCollector.html  Reproduce the problem, stop the JVM(s) completely, stop the WAIT collector, upload *.hcd, WAS logs, <TEMP>/healthcenter.*.log, and waitData 50 © 2012 IBM Corporation
  • 51. Example: Socket Read  Server socket that just waits: import java.io.*; import java.net.*; public class SocketDoNothing { public static void main(String[] args) { try { System.out.println("SocketDoNothing started"); int port = 23456; ServerSocket serverSocket = new ServerSocket(port); Socket socket = serverSocket.accept(); InputStream inputFromClient = socket.getInputStream(); OutputStream os = socket.getOutputStream(); byte b = (byte) inputFromClient.read(); while (b != -1) { System.out.println("Received byte = 0x" + Integer.toString(b, 16)); switch (b) { case 1: Thread.sleep(60000); break; } os.write(1); b = (byte) inputFromClient.read(); } os.close(); inputFromClient.close(); socket.close(); serverSocket.close(); } catch (Throwable t) { System.err.println("Error: " + t.getLocalizedMessage()); t.printStackTrace(); } } } 51 © 2012 IBM Corporation
  • 52. Example: Socket Read  Client with Health Center import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; public class HighWaiting { public static void main(String... args) { try { System.out.println("HighWaiting started"); Socket socket = new Socket("localhost", 23456); OutputStream os = socket.getOutputStream(); InputStream is = socket.getInputStream(); os.write(1); is.read(); os.write(-1); is.close(); os.close(); socket.close(); System.out.println("HighWaiting done"); } catch (Throwable t) { System.err.println("Error: " + t.getLocalizedMessage()); t.printStackTrace(); } } } 52 © 2012 IBM Corporation
  • 53. Example: Socket read results  HighWaiting barely shows up in the profiling data 53 © 2012 IBM Corporation