{"id":1839,"date":"2015-11-16T07:47:59","date_gmt":"2015-11-16T07:47:59","guid":{"rendered":"http:\/\/mevss.jku.at\/?page_id=1839"},"modified":"2017-08-30T08:18:25","modified_gmt":"2017-08-30T08:18:25","slug":"lock-contention-tracing","status":"publish","type":"page","link":"http:\/\/mevss.jku.at\/?page_id=1839","title":{"rendered":"Lock Contention Tracing"},"content":{"rendered":"<h3>Efficient Tracing and Versatile Analysis of Lock Contention in Java Applications on the Virtual Machine Level<\/h3>\n<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Overview<\/h2>\n<div class=\"tabcontent\">\n\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignright wp-image-2609\" src=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2012\/11\/dynatrace-logo_black_font-300x53.png\" alt=\"\" width=\"197\" height=\"35\" srcset=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2012\/11\/dynatrace-logo_black_font-300x53.png 300w, http:\/\/mevss.jku.at\/wp-content\/uploads\/2012\/11\/dynatrace-logo_black_font-768x137.png 768w, http:\/\/mevss.jku.at\/wp-content\/uploads\/2012\/11\/dynatrace-logo_black_font-1024x182.png 1024w, http:\/\/mevss.jku.at\/wp-content\/uploads\/2012\/11\/dynatrace-logo_black_font.png 2000w\" sizes=\"(max-width: 197px) 100vw, 197px\" \/><\/p>\n<p>Multi-core processors have become the norm from server-class machines to phones, and software developers must write concurrent code to benefit from their increasing processing power. However, implementing correct and scalable locking for accessing shared resources remains a challenge. Examining lock contention in an application at run time is vital to determine where more sophisticated but error-prone locking pays off.<\/p>\n<p>In our paper <i>Efficient Tracing and Versatile Analysis of Lock Contention in Java Applications on the Virtual Machine Level,<\/i> we describe a novel approach for analyzing lock contention in Java applications by tracing locking events in the Java Virtual Machine. Unlike common methods, our approach observes not only when a thread is blocked on a lock, but also which other thread blocked it by holding that lock, and records both their stack traces. This reveals the causes of lock contention instead of showing only its symptoms. We further devised a versatile tool for the analysis of the traces which enables users to identify locking bottlenecks and their characteristics in an effective way. We implemented our approach in the widely used HotSpot Virtual Machine, and with a mean run-time overhead of 7.8% for real-world multi-threaded benchmarks, we consider it efficient enough to monitor production systems.<\/p>\n<p><b>On this website, we provide downloads for our prototype Java Development Kit (JDK) and for our trace analysis tool, as well as their source code.<\/b><\/p>\n<p>Our research is supported by Dynatrace Austria and by the Christian Doppler Forschungsgesellschaft.<\/p>\n<figure id=\"attachment_1854\" aria-describedby=\"caption-attachment-1854\" style=\"width: 400px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2015\/11\/tracing-monitor-contention.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-1854\" src=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2015\/11\/tracing-monitor-contention.png\" alt=\"---\" width=\"400\" height=\"211\" srcset=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2015\/11\/tracing-monitor-contention.png 985w, http:\/\/mevss.jku.at\/wp-content\/uploads\/2015\/11\/tracing-monitor-contention-300x158.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-1854\" class=\"wp-caption-text\">The trace events which we record indicate which threads, methods and call chains are responsible for lock contention<\/figcaption><\/figure>\n<figure id=\"attachment_1855\" aria-describedby=\"caption-attachment-1855\" style=\"width: 400px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2016\/11\/products.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-1855\" src=\"http:\/\/mevss.jku.at\/wp-content\/uploads\/2016\/11\/products.png\" alt=\"asdfasdf\" width=\"400\" height=\"269\" \/><\/a><figcaption id=\"caption-attachment-1855\" class=\"wp-caption-text\">Our analysis tool breaks down the recorded contention by different aspects<\/figcaption><\/figure>\n<h4>Team<\/h4>\n<ul>\n<li><a href=\"http:\/\/mevss.jku.at\/?page_id=170\">Peter Hofer<\/a> (contact for inquiries)<\/li>\n<li><a href=\"http:\/\/mevss.jku.at\/?page_id=403\">David Gnedt<\/a><\/li>\n<li><a href=\"http:\/\/mevss.jku.at\/?page_id=1647\">Andreas Sch\u00f6rgenhumer<\/a><\/li>\n<li><a href=\"http:\/\/ssw.jku.at\/General\/Staff\/HM\/\">Hanspeter M\u00f6ssenb\u00f6ck<\/a><\/li>\n<\/ul>\n<p>\n<\/div><h2 class=\"tabtitle\">Downloads<\/h2>\n<div class=\"tabcontent\">\n<br \/>\nPlease cite as: <i>Efficient Tracing and Versatile Analysis of Lock Contention in Java Applications on the Virtual Machine Level<\/i>, in Proceedings of the 7th ACM\/SPEC International Conference on Performance Engineering (ICPE&#8217;16), Delft, Netherlands, 2016.<\/p>\n<p>On this page, you can download our prototype of a Java Development Kit (JDK) which traces lock contention in the executed application, as well as our analysis tool that visualizes the generated traces. All of our code is licensed under the GNU Public License (Copyright Dynatrace 2014, 2015).<\/p>\n<p>Please contact <a href=\"http:\/\/mevss.jku.at\/?page_id=170\">Peter Hofer<\/a> with questions.<\/p>\n<h4>Stable Version<\/h4>\n<p>This is the JDK and analysis tool as we describe it in our paper, plus minor improvements. The JDK is based on OpenJDK\u00a08 (8u102-b14) and is fully compatible to OpenJDK\u00a08. The JDK is supported <strong>only on Linux on 64-bit x86 hardware.<\/strong><\/p>\n<table style=\"width: 100%;\">\n<tbody>\n<tr>\n<th rowspan=\"2\">Java Development Kit<\/th>\n<td><b>Binary Distribution<\/b><br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/jdk8u102__lock-contention-tracing__2016-10-21.tar.bz2\">Download<\/a> (Linux x86-64; 67 MB)<\/td>\n<\/tr>\n<tr>\n<td><b>Source Code<\/b><br \/>\nUse Mercurial to clone the OpenJDK source tree from: <a href=\"http:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/\">http:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/<\/a>Apply these patches:<br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/hotspot__8u102-b14__lock-contention-tracing__2016-10-21.patch\">Patch for <i>hotspot<\/i> subrepository<\/a> (apply on <i>jdk8u102-b14<\/i>, commit <i>ac29c9c1193a<\/i>)<br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/jdk__8u102-b14__lock-contention-tracing__2016-10-21.patch\">Patch for <i>jdk<\/i> subrepository<\/a> (apply on <i>jdk8u102-b14<\/i>, commit <i>48c99b423839<\/i>)Follow the <a href=\"http:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/raw-file\/832508a6165c\/README-builds.html\">OpenJDK 8 build instructions<\/a>.<\/td>\n<\/tr>\n<tr>\n<th>Trace Analysis Tool<\/th>\n<td><a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/concurrencyvisualizer__2016-11-03.zip\">Java Application<\/a> (platform-independent; 18 MB)<\/p>\n<p>Extract and run with the launchers in the <i>bin\/<\/i> subdirectory.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Experimental Version<\/h4>\n<p>This version of our JDK is based on OpenJDK\u00a09 (9b140) and <strong>exclusively supports tracing VM-internal native locks.<\/strong> We tested the JDK only on Linux on 64-bit x86 hardware, but it should require only few changes to work on other platforms. Use the analysis tool of the stable version to analyze the traces.<\/p>\n<table style=\"width: 100%;\">\n<tbody>\n<tr>\n<th rowspan=\"2\">Java Development Kit<\/th>\n<td><b>Binary Distribution<\/b><br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/jdk9+140__lock-contention-tracing__2016-10-25.tar.bz2\">Download<\/a> (Linux x86-64; 157 MB)<\/td>\n<\/tr>\n<tr>\n<td><b>Source Code<\/b><br \/>\nClone the source tree from: <a href=\"http:\/\/hg.openjdk.java.net\/jdk9\/jdk9\/\">http:\/\/hg.openjdk.java.net\/jdk9\/jdk9\/<\/a>Apply these patches:<br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/hotspot__jdk-9+140__lock-contention-tracing__2016-10-25.patch\">Patch for <i>hotspot<\/i> subrepository<\/a> (apply on <i>jdk-9+140<\/i>, commit <i>fec31089c2ef<\/i>)<br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/jdk__jdk-9+140__lock-contention-tracing__2016-10-25.patch\">Patch for <i>jdk<\/i> subrepository<\/a> (apply on <i>jdk-9+140<\/i>, commit <i>e93b7ea55975<\/i>)Follow the <a href=\"http:\/\/hg.openjdk.java.net\/jdk9\/jdk9\/raw-file\/b0a80d214458\/README-builds.html\">OpenJDK 9 build instructions<\/a>.<\/td>\n<\/tr>\n<tr>\n<th>Trace Analysis Tool<\/th>\n<td>Use the trace analysis tool provided for the stable version above.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Original Version<\/h4>\n<p>This is the exact JDK and analysis tool as described and evaluated in our paper. The JDK is based on OpenJDK\u00a08 (8u45-b14) and is fully compatible to OpenJDK\u00a08. The JDK is supported <strong>only on Linux on 64-bit x86 hardware.<\/strong><\/p>\n<table style=\"width: 100%;\">\n<tbody>\n<tr>\n<th rowspan=\"2\">Java Development Kit<\/th>\n<td><b>Binary Distribution<\/b><br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/jdk8u45__lock-contention-tracing__2015-11-17.tar.bz2\">Download<\/a> (Linux x86-64; 67 MB)<\/td>\n<\/tr>\n<tr>\n<td><b>Source Code<\/b><br \/>\nClone the source tree from: <a href=\"http:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/\">http:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/<\/a>Apply these patches:<br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/hotspot__8u45-b14__lock-contention-tracing__2015-11-17.patch\">Patch for <i>hotspot<\/i> subrepository<\/a> (apply on <i>jdk8u45-b14<\/i>, commit <i>5321d26956b2<\/i>)<br \/>\n<a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/jdk__8u45-b14__lock-contention-tracing__2015-11-17.patch\">Patch for <i>jdk<\/i> subrepository<\/a> (apply on <i>jdk8u45-b14<\/i>, commit <i>20e6cadfac43<\/i>)Follow the <a href=\"http:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/raw-file\/832508a6165c\/README-builds.html\">OpenJDK 8 build instructions<\/a>.<\/td>\n<\/tr>\n<tr>\n<th>Trace Analysis Tool<\/th>\n<td><a href=\"http:\/\/ssw.jku.at\/General\/Staff\/PH\/lock-contention-tracing\/concurrencyvisualizer__2015-11-17.zip\">Java Application<\/a> (platform-independent; 16 MB)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<\/div><h2 class=\"tabtitle\">JDK Usage<\/h2>\n<div class=\"tabcontent\">\n\n<p>Our Java Development Kit (JDK) is based on OpenJDK and is fully compatible to OpenJDK in terms of the provided executables, the Java class library and language support, and even specific command-line parameters. Therefore, our JDK is suitable as a drop-in replacement for an existing OpenJDK installation and typically also for an Oracle JDK installation. Our additional lock contention tracing features must be enabled explicitly with command-line parameters, most importantly <code>-XX:+EnableEventTracing<\/code> and <code>-XX:EventTracingConfiguration=&lt;configuration&gt;<\/code>.<\/p>\n<p>For example, the following command launches the Java application from <code>application.jar<\/code> with event tracing enabled, and the trace is written to the file <code>\/some\/path\/file.trc<\/code>:<\/p>\n<p><code>\/path\/to\/java<br \/>\n-XX:+EnableEventTracing<br \/>\n-XX:EventTracingConfiguration=Output=\/some\/path\/file.trc<br \/>\n-jar application.jar<\/code><\/p>\n<p>Description of the most important parameters related to lock contention tracing:<\/p>\n<table style=\"width: 100%;\">\n<tbody>\n<tr>\n<th><b>Flag<\/b><\/th>\n<th><b>Description<\/b><\/th>\n<\/tr>\n<tr>\n<td>EnableEventTracing<\/td>\n<td>Activates tracing lock contention events (disabled by default).Example: <code>-XX:+EnableEventTracing<\/code> to enable.<br \/>\n<code>-XX:-EnableEventTracing<\/code> to disable (default).<\/td>\n<\/tr>\n<tr>\n<td>EventTracingConfiguration<\/td>\n<td>Configuration string that specifies how the recorded events should be processed. <code>Output<\/code> specifies that recorded events should be written to an uncompressed file. <code>Statistics<\/code> performs an online analysis of recorded events and writes the results to a text file on exit. The path of the output file can be specified, or alternatively, a file with a pre-defined name (<code>output.trc<\/code> or <code>trace-statistics.txt<\/code>) will be created in the current directory. In either case, existing files are overwritten without prompt.<\/p>\n<p>Examples:<br \/>\n<code>-XX:EventTracingConfiguration=Output<\/code><br \/>\n<code>-XX:EventTracingConfiguration=Output=\/some\/path\/uncompressed.trc<\/code><br \/>\n<code style=\"white-space: nowrap;\">-XX:EventTracingConfiguration=Statistics=\/some\/path\/statistics.txt<\/code><br \/>\n<!--<code>-XX:EventTracingConfiguration=CompressedOutput=\/some\/path\/compressed.trc.lz4<\/code>--><\/td>\n<\/tr>\n<tr>\n<td>EnableEventTracingParkEvents<\/td>\n<td>Activates tracing <code>park<\/code> and <code>unpark<\/code> calls (on by default). This captures contention from synchronization mechanisms implemented in Java, such as <code>ReentrantLock<\/code> and <code>ReentrantReadWriteLock<\/code> and most other code in <code>java.util.concurrent<\/code>. When disabled, only contention from Java intrinsic locks (monitors) is captured.Example:<br \/>\n<code>-XX:-EnableEventTracingParkEvents<\/code> to disable.<\/td>\n<\/tr>\n<tr>\n<td>EventTracingBufferCapacity<\/td>\n<td>The size of a per-thread trace buffer in bytes (default: 16384). Increasing this value increases memory usage, but reduces buffer management cost. Note that actual buffer sizes are randomized, with this value being the mean buffer size.Example:<br \/>\n<code>-XX:EventTracingBufferCapacity=32768<\/code><\/td>\n<\/tr>\n<tr>\n<td>EnableEventTracingStackTraces<\/td>\n<td>Enables capturing stack traces for trace events (on by default).Example:<br \/>\n<code>-XX:-EnableEventTracingStackTraces<\/code> to disable.<\/td>\n<\/tr>\n<tr>\n<td>EventTracingStackDepthLimit<\/td>\n<td>Specifies the maximum number of stack frames (not including inlined frames) that are captured in one stack walk (default: 128). Increasing this might require increasing <code>EventTracingBufferCapacity<\/code> as well.Example:<br \/>\n<code>-XX:EventTracingStackDepthLimit=64<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<\/div><h2 class=\"tabtitle\">Analysis Tool Usage<\/h2>\n<div class=\"tabcontent\">\n\n<p>Please watch our video for instructions on how to use our analysis tool.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/DwBhavdvtMg\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n<\/div><h2 class=\"tabtitle\">Publications<\/h2>\n<div class=\"tabcontent\">\n\n<ul>\n<li><a href=\"http:\/\/dl.acm.org\/citation.cfm?id=3030234\">Efficient Sampling-based Lock Contention Profiling in Java<\/a>, in Proceedings of the 8th ACM\/SPEC International Conference on Performance Engineering (ICPE&#8217;17), L&#8217;Aquila, Italy, 2017.<\/li>\n<li><a href=\"http:\/\/epub.jku.at\/obvulihs\/content\/titleinfo\/1825350?lang=en\">Efficient Sampling-based Lock Contention Profiling in Java<\/a>, Master&#8217;s Thesis, Andreas Sch\u00f6rgenhumer, Johannes Kepler University, Linz, Austria, 2017.<\/li>\n<li><a href=\"http:\/\/ssw.jku.at\/Teaching\/PhDTheses\/Hofer\/index.html\">Method Profiling and Lock Contention Profiling on the Java Virtual Machine Level<\/a>, PhD Thesis, Peter Hofer, Johannes Kepler University, Linz, Austria, 2016.<\/li>\n<li><i>Runtime Analysis of High-Level Java Synchronization Mechanisms on the Virtual Machine Level,<\/i> Master&#8217;s Thesis, David Gnedt, Johannes Kepler University, Linz, Austria, 2016.<\/li>\n<li><a href=\"http:\/\/dl.acm.org\/authorize?N03841\">Efficient Tracing and Versatile Analysis of Lock Contention in Java Applications on the Virtual Machine Level<\/a>, in Proceedings of the 7th ACM\/SPEC International Conference on Performance Engineering (ICPE&#8217;16), Delft, Netherlands, 2016.<\/li>\n<li><a href=\"http:\/\/dl.acm.org\/authorize?N03842\">Efficient Dynamic Analysis of the Synchronization Performance of Java Applications<\/a>, in Proceedings of the 13th International Workshop on Dynamic Analysis (WODA&#8217;15), Pittsburgh, PA, USA, 2015.<\/li>\n<\/ul>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Efficient Tracing and Versatile Analysis of Lock Contention in Java Applications on the Virtual Machine Level Multi-core processors have become the norm from server-class machines to phones, and software developers must write concurrent code to benefit from their increasing processing power. However, implementing correct and scalable locking for accessing shared resources remains a challenge. Examining &hellip; <a href=\"http:\/\/mevss.jku.at\/?page_id=1839\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Lock Contention Tracing<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/mevss.jku.at\/index.php?rest_route=\/wp\/v2\/pages\/1839"}],"collection":[{"href":"http:\/\/mevss.jku.at\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/mevss.jku.at\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/mevss.jku.at\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/mevss.jku.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1839"}],"version-history":[{"count":50,"href":"http:\/\/mevss.jku.at\/index.php?rest_route=\/wp\/v2\/pages\/1839\/revisions"}],"predecessor-version":[{"id":2617,"href":"http:\/\/mevss.jku.at\/index.php?rest_route=\/wp\/v2\/pages\/1839\/revisions\/2617"}],"wp:attachment":[{"href":"http:\/\/mevss.jku.at\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}