tip from connect 2014: java performance analysis and troubleshooting
DESCRIPTION
This particular tip deals with performance analysis and troubleshooting. Mark Myers (London Developer Co-op) and Julian Robichaux (panagenda) focus on code optimization, troubleshooting with FindBugs, analyzing Java Memory Usage and a whole lot more. The rest of thir presentation (which you can download for free in the IBM Connect 2014 community on SocialBizUG.org) is packed full of useful information relational data access; images, PDFs, and Plugins; IDEs other than Domino Designer you may want to consider; and tons of resources.TRANSCRIPT
© 2014 IBM Corporation
SHOW104: Practical Java
Mark Myers, London Developer Coop Julian Robichaux, panagenda
154
Performance Analysis and Troubleshooting
Code Optimization
Make your code work first, then worry about speed – You always want working code to fall back on
Is it fast enough? Leave it alone.
An elegant solution that is slightly slower is often better than an ugly solution that is slightly faster
Making code shorter doesn’t make it faster
Keep the code readable and easy to troubleshoot
Don’t assume you know where the bottleneck is
“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil”
- Donald Knuth
Static Code Analyzers
FindBugs is a great tool for finding potential problems
Bugs grouped by categories – Scariest – Scary – Troubling
Also subcategories like “Correctness”, “Security”, “Performance”, and “Dodgy Code”
New cloud option for development teams – Rank bugs, assign fixes
http://findbugs.sourceforge.net
http://www.cs.umd.edu/~pugh/MistakesThatMatter.pdf
FindBugs
FindBugs
Debugging, Logging, and Unit Testing
Mark and Julian did a 2-hour presentation on debugging, logging, and unit testing at Lotusphere 2012
– Please see the slides at: – http://londondevelopercoop.com/ldc.nsf/pages/goodies
Highlights: – How to add unit testing to Java code in DDE – How to add unit testing to JavaScript code – Debugging Java agents on Notes clients and Domino servers – Debugging Java classes used by XPages – Tips for using Java logging
Common Bottlenecks
Some other guy’s server
Slow database queries
Memory issues – Leaks (less common than you’d think) – Too much cached information
• Especially large objects, strings, XML – Strong references
Loading and unloading resources
Non-lazy initialization of objects
Slow or broken network connection
Simulating Poor Network Connections
http://www.charlesproxy.com
http://jagt.github.io/clumsy
Network Link Conditioner (OSX) – XCode > Open Developer Tool > More Developer Tools
Analyzing Java Memory Usage
Used for: – Tracking down memory leaks – Finding high-memory-use objects (and arrays) – Finding objects that are unexpectedly still in memory
IBM Heap Analyzer – https://www.ibm.com/developerworks/community/alphaworks/tech/heapanalyzer – http://www-01.ibm.com/support/docview.wss?uid=swg27006624&aid=1
YourKit Java profiling app – http://yourkit.com – http://notesin9.com/index.php/2012/11/29/notesin9-091-xpages-memory-profiling-part-1
Eclipse Memory Analysis Tool – http://www.eclipse.org/mat/downloads.php – http://lazynotesguy.net/blog/2013/08/30/wheres-my-memory-gone-peeking-inside-jvms-
heap-part-1-installation – http://lazynotesguy.net/blog/2013/10/04/peeking-inside-jvms-heap-part-2-usage
Generating Heap Dumps with Notes/Domino
Domino XPages – tell http xsp heapdump – XPages Toolbox ( http://www.openntf.org/p/XPages%20Toolbox )
Notes Client (Expeditor) – notes\framework\rcp\rcplauncher.exe -com.ibm.rcp.core.logger#dump heap -dumps heapdump – writes to notes\data\workspace\logs\heapdump.###.phd by default – You can also do a core (thread) dump with:
• notes\framework\rcp\rcplauncher.exe -com.ibm.rcp.core.logger#dump threads -dumps javacore
Directly from Java – com.ibm.jvm.Dump.HeapDump(); – writes to notes\framework\heapdump.###.phd when run from an agent
Access Connect Online to complete your session surveys using any: – Web or mobile browser – Connect Online kiosk onsite
167
Mark Myers London Developer Coop [email protected] Twitter: @stickfight
Julian Robichaux panagenda [email protected] Twitter: @jrobichaux
168
Acknowledgements and Disclaimers
© Copyright IBM Corporation 2014. All rights reserved. U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. IBM, the IBM logo, ibm.com, IBM WebSphere, IBM Notes, IBM Connections, Rational, and DB2 are trademarks or registered trademarks of
International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (® or ™), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
Availability. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates.
The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided AS-IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software.
All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.