Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Tip or Technique Java Garbage Collection Product(s): IBM Cognos 8 Area of Interest: Performance Java Garbage Collection Page 2 of 16 Copyright Copyright © 2008 Cognos ULC (formerly Cognos Incorporated). Cognos ULC is an IBM Company. While every attempt has been made to ensure that the information in this document is accurate and complete, some typographical errors or technical inaccuracies may exist. Cognos does not accept responsibility for any kind of loss resulting from the use of information contained in this document. This document shows the publication date. The information contained in this document is subject to change without notice. Any improvements or changes to the information contained in this document will be documented in subsequent editions. This document contains proprietary information of Cognos. All rights are reserved. No part of this document may be copied, photocopied, reproduced, stored in a retrieval system, transmitted in any form or by any means, or translated into another language without the prior written consent of Cognos. Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. All other names are trademarks or registered trademarks of their respective companies. Information about Cognos products can be found at www.cognos.com This document is maintained by the Best Practices, Product and Technology team. You can send comments, suggestions, and additions to [email protected] . IBM Cognos Proprietary Information Java Garbage Collection Page 3 of 16 Contents 1 INTRODUCTION ............................................................................................ 4 1.1 1.2 1.3 PURPOSE ................................................................................................................ 4 APPLICABILITY ......................................................................................................... 4 EXCLUSIONS AND EXCEPTIONS ..................................................................................... 4 2 JAVA COMMAND-LINE OPTIONS .................................................................. 5 2.1 2.2 2.3 SUN ...................................................................................................................... 5 IBM...................................................................................................................... 5 HP ....................................................................................................................... 5 3 STARTUP ....................................................................................................... 6 3.1 3.2 3.3 LIMITATIONS ........................................................................................................... 6 STARTUP.BAT ........................................................................................................... 6 COGBOOTSTRAPSERVICE ............................................................................................. 9 4 MONITORING GARBAGE COLLECTION ....................................................... 11 4.1 GCVIEWER FROM TAGTRAUM .................................................................................... 11 5 ADDITIONAL JAVA PARAMETERS ............................................................... 13 5.1 5.2 5.3 HTTP PROXY ........................................................................................................ 13 ORACLE JDBC TRACING ........................................................................................... 14 DB2 JDBC TRACING ............................................................................................... 14 6 REFERENCES ............................................................................................... 15 6.1 6.2 6.3 6.4 6.5 SUN .................................................................................................................... 15 IBM.................................................................................................................... 15 HP ..................................................................................................................... 15 TAGTRAUM INDUSTRIES ........................................................................................... 15 TOMCAT PERFORMANCE............................................................................................ 15 IBM Cognos Proprietary Information Java Garbage Collection Page 4 of 16 1 Introduction 1.1 Purpose The allocation of Heap memory is one of the few tuneable parameters for a Servlet Engine. Both excessive and insufficient Heap can cause performance degradation due to Garbage Collection. This document offers guidance on how to capture and observe the use of Heap memory by Java for IBM Cognos 8 or IBM Cognos ReportNet. 1.2 Applicability Instructions are provided only for integration with the Apache Tomcat servlet engine embedded with the IBM Cognos products. When using an alternate Application Server similar steps will be necessary but may be applied using that product's Administrative User Interface. 1.3 Exclusions and Exceptions Instructions are appropriate for all versions of IBM Cognos 8 and IBM Cognos Report Net only when using Java 1.4.x or higher. The Java command-line parameters indicated are not all supported by Java 1.3.x. IBM Cognos Proprietary Information Java Garbage Collection Page 5 of 16 2 Java Command-line options We list here only the parameters which affect Garbage Collection logging. There are many more supported and unsupported parameters which are not directly relevant. 2.1 Sun -verbose:gc Prints out information about garbage collections. The default destination is StdOut, so to redirect the same information to a file, use – Xloggc:<file> Example: [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs] -Xloggc:<filename> Prints information about garbage collections to the specified file. -XX:+PrintGCDetails Instructs the VM to be more verbose when printing out garbage collecion data. Specifically it does not only tell you that there was a collection, but also what impact it had on the different generations. This flag is very useful when tuning generation sizes. 2.2 IBM -verbose:gc Prints out information about garbage collections to standard out. -Xverbosegclog:<filename[,X,Y]> Prints out information about garbage collections to a file. If the integers X and Y are specified, the output is redirected to X files each containing output from Y GC cycles. 2.3 HP -Xverbosegc[:help]|[0|1][:file=[stdout|stderr|<filename>]] :help prints this message. 0|1 controls the printing of heap information: 0 Print after every Old Generation GC or Full GC 1 (default) Print after every Scavenge and Old Generation GC or Full GC :file=[stdout|stderr|<filename>] specifies output file stderr (default) directs output to standard error stream IBM Cognos Proprietary Information Java Garbage Collection Page 6 of 16 stdout directs output to standard output stream <filename> file to which the output will be written 3 Startup 3.1 Limitations Java applications scale "out" better than "up". That is, performance is better by distributing components of an application across many moderate sized Servlet Containers rather than a monolithic instance. Each Servlet Container represents one invocation of Java, and hence may also bind to a distinct CPU. The IBM Cognos 8 application uses Java Native Methods for interaction with external Security Namespaces, and for some Cryptographic functions. These are 32bit libraries, so a 32bit JRE is required (a 64bit JRE cannot load 32bit JNI libraries). A 32bit application can address a very finite amount of RAM. If the application attempts to allocate more RAM than it can address then the Operating System will terminate the application. You will notice that even if Maximum Java Heap is 768MB (recommended), you may observe that the total memory utilisation by the Java process exceeds 1GB. This additional utilisation is Java itself plus JNI. Java itself also needs some memory for its own operation. The sum of Java working memory, maximum Heap, and JNI must not exceed addressable memory. If the JNI is unable to allocate memory for eg User Session Information [in the CAM subcomponent of the Content Manager] then Java may be terminated. JNI memory is not subject to Garbage Collection, as that memory is managed entirely by the JNI libraries that extend Java. Problems have been observed allocating Java Heap > 1152MB on Windows. IBM Cognos recommend: Heap(Windows) < 1152MB Java + Heap + JNI < 2GB IBM Cognos further recommends that you do NOT assign the Initial (-Xms) and Maximum (-Xmx) Heap to the same values as this practice degrades performance of the garbage collector. 3.2 startup.bat startup.bat (or startup.sh on Unix) is located at "c8_location/bin/startup.bat". This is not an IBM Cognos-supported tool for starting the IBM Cognos-embedded Tomcat but may be useful while debugging an errant installation, or if unable to create the Service in Windows. The startup.bat constructs a Java Command Line which directly invokes Tomcat. It does not start any Service, and particularly does not start the IBM Cognos watchdog process "cogbootstrapservice" which is normally used to ensure that Tomcat is automatically restarted after any unexpected failure. IBM Cognos Proprietary Information Java Garbage Collection Page 7 of 16 The parameters indicated in startup.bat assume a Sun JRE. If using an IBM JRE then CATALINA_OPTS must be modified. @rem Copyright (C) 2006 Cognos Incorporated. All rights reserved. @rem Cognos (R) is a trademark of Cognos Incorporated. @echo off setlocal set CATALINA_HOME=..\tomcat4.1.27 if "%JAVA_HOME%" == "" set JAVA_HOME=..\bin\jre\1.4.2 set CATALINA_TMPDIR=..\temp IF NOT EXIST %CATALINA_TMPDIR% md %CATALINA_TMPDIR% rem uncomment next line to run tomcat with debug settings, rem so you can attach a debugger. rem set DEBUG_OPTS=-Xdebug -Xnoagent Xrunjdwp:transport=dt_socket,address=9091,server=y,suspend=y Djava.compiler=NONE rem set set set uncomment next lines to DEBUG_OPTS=%DEBUG_OPTS% DEBUG_OPTS=%DEBUG_OPTS% DEBUG_OPTS=%DEBUG_OPTS% enable GarbageCollection logging -Xincgc -Xloggc:../logs/gc.log -XX:+PrintGCDetails rem "for machines with 1GB RAM" set CATALINA_OPTS=-Xmx768m -XX:MaxNewSize=384m -XX:NewSize=192m XX:MaxPermSize=128m %DEBUG_OPTS% rem "for machines with 2GB RAM" rem set CATALINA_OPTS=-Xmx1152m -XX:MaxNewSize=576m -XX:NewSize=288m XX:MaxPermSize=128m %DEBUG_OPTS% rem "for machines with 3GB RAM" rem set CATALINA_OPTS=-Xmx1536m -XX:MaxNewSize=768m -XX:NewSize=384m XX:MaxPermSize=128m %DEBUG_OPTS% call "%CATALINA_HOME%\bin\catalina" run %* endlocal As Windows cannot manage a Heap larger than 1152MB then the section "for machines with 3GB RAM" above should not be used. IBM Cognos Proprietary Information Java Garbage Collection Page 8 of 16 In the last line where "catalina" is invoked, the parameter "run" instructs Tomcat to run in a foreground window –useful for observing TCP or JDBC errors. The default is "start" which runs Tomcat in a background window. To stop Tomcat, either terminate the Command Window or invoke "shutdown.bat". IBM Cognos Proprietary Information Java Garbage Collection 3.3 Page 9 of 16 cogbootstrapservice The Windows Service "cogbootstrapservice" uses the information in "c8_location/bin/bootstrap_win32.xml" and "c8_location/configuration/cogstartup.xml" to construct a Java Command-line which invokes Tomcat. Similarly, the startup procedure "cogconfig.sh –s" on Unix uses the information in "c8_location/bin/bootstrap_<OS>.xml" [where <OS> is "aix", etc] to construct the Java Command-line. If using an alternate Application Server (eg IBM WebSphere) then this file is not used. <process name="catalina"> <start> <spawn sync="0" wait_time="5"> <path quoteAsParam="true">${java_home}/bin/java.exe</path> <param>-Xrs</param> <param>-Xmx${dispatcherMaxMemory}m</param> <param condName="${java_vendor}" condValue="Sun">XX:MaxNewSize=${dispatcherMaxMemoryBy2}m</param> <param condName="${java_vendor}" condValue="Sun">XX:NewSize=${dispatcherMaxMemoryBy4}m</param> <param condName="${java_vendor}" condValue="Sun">XX:MaxPermSize=128m</param> <!-- uncomment these for debug --> <!— (useless without Source Code) <param>-Xdebug</param> <param>-Xnoagent</param> <param>Xrunjdwp:transport=dt_socket,address=9091,server=y,suspend=y</param> <param>-Djava.compiler=NONE</param> --> <!-- end debug params --> <!-- uncomment these for garbage collection logging --> <!-< param condName="${java_vendor}" condValue="Sun">-Xincgc</param> < param condName="${java_vendor}" condValue="Sun">Xloggc:${install_path}/logs/gc.log</param> < param condName="${java_vendor}" condValue="Sun">XX:+PrintGCDetails</param> < param condName="${java_vendor}" condValue="IBM">verbose:gc</param> < param condName="${java_vendor}" condValue="IBM">Xverbosegclog:${install_path}/logs/gc.log</param> IBM Cognos Proprietary Information Java Garbage Collection Page 10 of 16 --> <!-- end gc --> <param>-cp</param> <param>"${install_path}/tomcat4.1.27/bin/bootstrap.jar;${java_home}/lib/ tools.jar"</param> <param>"-Dcatalina.base=${install_path}/tomcat4.1.27"</param> <param>"-Dcatalina.home=${install_path}/tomcat4.1.27"</param> <param>"-Djava.io.tmpdir=${temp}"</param> <param>org.apache.catalina.startup.Bootstrap</param> <param>start</param> </spawn> </start> … … … Currently (IBM Cognos 8.1 mr2) the condValue element above supports only Sun and IBM. If using HP's JVM then merely use the following fragment to capture Garbage Collection logs: <param>-Xverbosegc:file=${install_path}/logs/gc.log</param> The ClassPath ("-cp") specifies only the JAR files necessary to start Tomcat itself. Tomcat uses the information in "server.xml" and each deployed application's Deployment Descriptor "web.xml" to locate and load the JAR files of each Servlet. See http://tomcat.apache.org/tomcat-4.1-doc/config/index.html for more details. IBM Cognos Proprietary Information Java Garbage Collection Page 11 of 16 4 Monitoring Garbage Collection 4.1 GCViewer from TagTraum See http://www.tagtraum.com/gcviewer.html This tool allows you to retrieve Garbage Collection Logs directly from a URL as well as from a file. If you assign an Alias to the "c8_location/logs" or configure the Garbage Collection logs to be written to "c8_location/webcontent/gc.log" then you can observe the Heap utilisation remotely, eg: • if written to "c8_location/logs/gc.log" and is assigned to an alias then http://webserver:80/cognos8/logs/gc.log • if written to "c8_location/webcontent/gc.log" then http://webserver:80/cognos8/gc.log • if written to "c8_location/webapps/p2pd/gc.log" (IBM Cognos-supplied Tomcat only) then http://appserver:9300/p2pd/gc.log In the sample graph above you can see the Actual heap utilisation in the sawtooth Blue line. Each "tooth" represents a garbage collection. The Red shading shows the Maximum heap utilisation over time. IBM Cognos Proprietary Information Java Garbage Collection Page 12 of 16 You need to size the "-Xmx" Java parameter to represent slightly more than the observed Maximum Utilisation. Cognos recommends 768MB in most cases, and that you should distribute Cognos components over multiple Java Servlet Containers rather than creating a monolithic container. Additional Java parameters may be used to manage the size of the different generation portions of the Heap which are GC'd differently. IBM Cognos Proprietary Information Java Garbage Collection Page 13 of 16 5 Additional Java Parameters 5.1 HTTP Proxy If operating IBM Cognos 8 in a network that requires a Proxy Server to access the Internet, then IBM Cognos 8 may be unable to access RSS sites. You can modify the Java Command-line to specify HTTP Proxy settings so that the RSS Client within the Presentation Service of the IBM Cognos 8 servlet is able to retrieve the RSS content. Example RSS feeds that you could add to a Page in IBM Cognos 8: • IBM Cognos http://www.cognos.com/rss/ o SupportLink http://support.cognos.com/en/gcs/rss/supportlink.xml o News Releases http://www.cognos.com/rss/cognosnewsreleases.xml • BBC World News http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml • New York Times International News http://www.nytimes.com/services/xml/rss/nyt/International.xml Add the bolded fragment below into the <start> section of "c8_location/bin/bootstrap_<OS>.xml" amongst the <param> entries: <!-- uncomment these to enable Proxy access to Internet --> <!-<param>-Dhttp.proxyHost=YourProxyServer</param> <param>-Dhttp.proxyPort=3128</param> <param>-Dhttp.nonProxyHosts=localhost</param> --> <!-<param>-Dhttp.proxyUser=username</param> <param>-Dhttp.proxyPassword=password</param> --> <!-- end proxy --> <param>"-cp"</param> IBM Cognos Proprietary Information Java Garbage Collection 5.2 Page 14 of 16 Oracle JDBC Tracing If experiencing problems connecting from the Content Manager to an Oracle Content Store, or from the Scheduling & Delivery Service to the Notification Store, or from Logging Service to an Oracle Audit database then you may need to enable JDBC Tracing. Refer to http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#32_ 00 You must replace the "classes12.jar" with the debugging-enabled version "classes12_g.jar", or "ojdbc14.jar" with "ojdbc14_g.jar", and must add the bolded fragment below into the <start> section of "c8_location/bin/bootstrap_<OS>.xml" amongst the <param> entries: <!-- uncomment these to enable Oracle JDBC tracing --> <!-<param>-Doracle.jdbc.Trace=true</param> <param>-Doracle.jdbc.LogFile=${install_path}/logs/ojdbc.log</param> --> <!-- end Oracle trace --> <param>"-cp"</param> Note that issues involving interaction between Reports and Oracle are not captured by these logs. The Report Servers use Oracle Native connectivity (OCI), not JDBC. 5.3 DB2 JDBC Tracing The DB2 JDBC driver "db2java.jar" is a JDBC Type-II driver which uses the native DB2 Client libraries to connect to the database. JDBC tracing is enabled in the client configuration files, and does not require changes to the Java command-line. Refer: • http://www128.ibm.com/developerworks/db2/library/techarticle/0205bargas/0205bar gas.html IBM Cognos Proprietary Information Java Garbage Collection Page 15 of 16 6 References 6.1 Sun Java Tuning Whitepaper http://java.sun.com/performance/reference/whitepapers/tuning.html Tuning Garbage Collection with the 1.4.2 Java Virtual Machine http://java.sun.com/docs/hotspot/gc1.4.2/index.html VM flags http://www.tagtraum.com/gcviewer-vmflags.html#sun 6.2 IBM IBM JVM Garbage Collection and Storage Allocation techniques ftp://www6.software.ibm.com/software/developer/jdk/diagnosis/GCandMemory042005.pdf Tivoli Performance Viewer http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm .websphere.nd.doc/info/ae/ae/cprf_tpv.html VM flags http://www.tagtraum.com/gcviewer-vmflags.html#ibm 6.3 HP HPjtune http://www.hp.com/products1/unix/java/java2/hpjtune/index.html VM flags http://www.hp.com/products1/unix/java/infolibrary/prog_guide/xverbosegc_1-41.html?jumpid=reg_R1002_USEN 6.4 TagTraum Industries http://www.tagtraum.com/gcviewer.html 6.5 Tomcat Performance http://tomcat.apache.org/articles/performance.pdf IBM Cognos Proprietary Information Java Garbage Collection IBM Cognos Proprietary Information Page 16 of 16