Java Performance Tuning 2nd edition - Jack Shirazi

Identification of the cause of the performance bottleneck is a science, not an art.

Measure/Profile current system in terms of

    Response time/TPS
    Memory
    Disk I/O
    CPU
    Concurrency
    
per layer and end to end for transactions identified by business in the descending order of risk or target volume per unit interval

Freeze them so that they can be served as reference at any point of time. This version of the software at any time should be installable to demostrate the effect of the changes made later.

Get to know the benchmark figures of performance of the software/hardware platform from industry.
What are the SLA the application has to conform to? Define them if they do not exist already and strive to achieve them. Agreeing on targets before tuning makes everything clear to everyone.

Follow a top-down approach, come up with observations and take direction from management on proceeding with the next set of efforts. Document all such decisions. Suggest not based on gut-feel but based on repeatable results of experimental evidence. Communication of your effort daily to management and taking their suggestions frequently is vital, as performance testing/tuning is an incremental R&D activity and some times lot of effort may go in the wrong direction or may require more time to get a solution. Always keep track of the problem perceived by management about the application and try to allieviate it.

Understand the cause
Hypothesize a solution
Test Hypothesis.



The trouble with doing something right the first time is that nobody appreciates how difficult it was.


There is a VM overhead for Java programs.
Slow and Fast are relative. Don't use relative terms, talk in terms of metrics.

JDK 1.3 introduced a new java.awt.Robot class, which provides for generating native system-input events, primarily to support automated testing of Java GUIs.

Sequential or Parallel.

The application has to be limited by something, or it would take no time at all to run.Solving one issue uncovers others. This process goes deeper. Finally the optimum performance is achieved on a hardware.

Product performance testing involves benchmarking on different hardwares.
Projects are usually confined to one set of hardware,software.
Cost/Time/Effort involved in making the changes suggested have to be mentioned while making recommendations.

Automate the process of testing and graphing, so that it can be repeated after applying fixes easily. Ability to compare across the test runs, after tuning is useful.

Identify if tuning is transaction, parameter, or concurrency dependant.

Perceived Performance
When the test is on, run a manual user to check user perception.
If you give users an expectancy of how long a particular task might take and why, they often accept that this is as long as it has to take and adjust their expectations.
Sometimes the users bandwidth might be the cause of slowness perceived.
Do not give users momentary false expectation that download is complete when it has not in reality but only a component has been.
Give the user a choice to decide between better performance or functionality.
Is the UI responsive?
Does  UI allow user to cancel any task perceived as long by user?

Do Threading,Streaming,Caching to appear faster.

Every atomic change has to be measured distinctively. Do not make more than 1 change at a time before retesting and document all changes.


If it ain't broke,don't fix it.

Is the priority of the process changing with time.
Know the options of netstat,iostat,vmstat,sar,top,ps,snoop,ndd,tcpdump,ethereal,sysstat,mpstat

Starting app with -verbosegc option gives app's GC stats.
JDK comes with minimal profiler which can be enabled by Xrunhprof:file=<filename>
Method profiling can be done by java -Xrunhprof:cpu=samples,thread=y <classname>
jhat included in JDK is Java Heap Analysis Tool.

The JDK provides two methods for monitoring the amount of memory used by the runtime system.
The methods are freeMemory( ) and totalMemory( ) in the java.lang.Runtime class.

Between client/server communications, the number of transfers and the amount of data transferred,and bandwidth limit performance.

If RMI is used for communication, -Djava.rmi.server.logCalls=true <ServerClass> can be used to log the calls. A program can be written to intercept the socket communication that will serve as passthrough, as FedEx reliability team has done.



Comments

Popular posts from this blog

How to get started with Vue in under a minute?

aigiri nandini - Brodha V you rock