giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pava...@apache.org
Subject git commit: updated refs/heads/trunk to 400b770
Date Tue, 13 May 2014 22:04:36 GMT
Repository: giraph
Updated Branches:
  refs/heads/trunk 61cd43b19 -> 400b7706a


GIRAPH-897: Add an option to dump only live objects to JMap (edunov via pavanka)


Project: http://git-wip-us.apache.org/repos/asf/giraph/repo
Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/400b7706
Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/400b7706
Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/400b7706

Branch: refs/heads/trunk
Commit: 400b7706ab28f138923e6db5b31fda28f1458917
Parents: 61cd43b
Author: Pavan Kumar <pavanka@fb.com>
Authored: Tue May 13 15:00:13 2014 -0700
Committer: Pavan Kumar <pavanka@fb.com>
Committed: Tue May 13 15:00:45 2014 -0700

----------------------------------------------------------------------
 CHANGELOG                                       |  4 ++-
 .../org/apache/giraph/conf/GiraphConstants.java |  9 ++++++
 .../main/java/org/apache/giraph/utils/JMap.java | 33 ++++++++++++++++++--
 .../apache/giraph/utils/JMapHistoDumper.java    |  5 ++-
 4 files changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/giraph/blob/400b7706/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index efc76b6..b51ccf6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,9 @@
 Giraph Change Log
 
 Release 1.1.0 - unreleased
-  GIRAPH-895 : Trim the edges in Giraph (edunov via pavanka)
+  GIRAPH-897: Add an option to dump only live objects to JMap (edunov via pavanka)  
+
+  GIRAPH-895: Trim the edges in Giraph (edunov via pavanka)
 
   GIRAPH-889: Update Yourkit Profiler (yhdong via pavanka)
 

http://git-wip-us.apache.org/repos/asf/giraph/blob/400b7706/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
index e791d62..7f1317f 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
@@ -393,6 +393,15 @@ public interface GiraphConstants {
           "Configuration key for how many lines to print");
 
   /**
+   * Configuration key for printing live objects only
+   * This option will trigger Full GC for every jmap dump
+   * and so can significantly hinder performance.
+   */
+  BooleanConfOption JMAP_LIVE_ONLY =
+      new BooleanConfOption("giraph.jmap.histo.live", false,
+          "Only print live objects in jmap?");
+
+  /**
    * Minimum percent of the maximum number of workers that have responded
    * in order to continue progressing. (float)
    */

http://git-wip-us.apache.org/repos/asf/giraph/blob/400b7706/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java b/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
index 19c8efd..92dd9e2 100644
--- a/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
+++ b/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
@@ -34,6 +34,8 @@ public class JMap {
   public static final String CMD = "jmap ";
   /** Arguments to pass in to command */
   public static final String ARGS = " -histo ";
+  /** This option will print out onlu live objects */
+  private static String LIVE_HISTO_OPTION = " -histo:live ";
 
   /** Do not construct */
   protected JMap() { }
@@ -55,6 +57,17 @@ public class JMap {
    * Run jmap, print numLines of output from it to stderr.
    *
    * @param numLines Number of lines to print
+   * @param liveObjectsOnly Should we only print non GC-able objects?
+   */
+  public static void heapHistogramDump(int numLines,
+                                       boolean liveObjectsOnly) {
+    heapHistogramDump(numLines, liveObjectsOnly, System.err);
+  }
+
+  /**
+   * Run jmap, print numLines of output from it to stderr.
+   *
+   * @param numLines Number of lines to print
    */
   public static void heapHistogramDump(int numLines) {
     heapHistogramDump(numLines, System.err);
@@ -67,11 +80,27 @@ public class JMap {
    * @param printStream Stream to print to
    */
   public static void heapHistogramDump(int numLines, PrintStream printStream) {
+    heapHistogramDump(numLines, false, printStream);
+  }
+
+  /**
+   * Run jmap, print numLines of output from it to stream passed in.
+   *
+   * @param numLines Number of lines to print
+   * @param liveObjectsOnly Should we only print non GC-able objects?
+   * @param printStream Stream to print to
+   */
+  private static void heapHistogramDump(int numLines,
+                                        boolean liveObjectsOnly,
+                                        PrintStream printStream) {
     try {
-      Process p = Runtime.getRuntime().exec(CMD + ARGS + getProcessId());
+      String args = liveObjectsOnly ? LIVE_HISTO_OPTION : ARGS;
+      Process p = Runtime.getRuntime().exec(CMD + args + getProcessId());
       BufferedReader in = new BufferedReader(
           new InputStreamReader(p.getInputStream(), Charset.defaultCharset()));
-      printStream.println("JMap histo dump at " + new Date());
+      printStream.println("JMap " +
+          (liveObjectsOnly ? "histo:live" : "histo") +
+          " dump at " + new Date());
       String line = in.readLine();
       for (int i = 0; i < numLines && line != null; ++i) {
         printStream.println("--\t" + line);

http://git-wip-us.apache.org/repos/asf/giraph/blob/400b7706/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java b/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
index aedee6c..3bcf42e 100644
--- a/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
+++ b/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
@@ -36,6 +36,8 @@ public class JMapHistoDumper implements MasterObserver, WorkerObserver {
   private int sleepMillis;
   /** How many lines of output to print */
   private int linesToPrint;
+  /** Should only print live objects */
+  private boolean liveObjectsOnly;
 
   /** The jmap printing thread */
   private Thread thread;
@@ -75,7 +77,7 @@ public class JMapHistoDumper implements MasterObserver, WorkerObserver {
       @Override
       public void run() {
         while (!stop) {
-          JMap.heapHistogramDump(linesToPrint);
+          JMap.heapHistogramDump(linesToPrint, liveObjectsOnly);
           try {
             Thread.sleep(sleepMillis);
           } catch (InterruptedException e) {
@@ -100,6 +102,7 @@ public class JMapHistoDumper implements MasterObserver, WorkerObserver
{
   public void setConf(ImmutableClassesGiraphConfiguration configuration) {
     sleepMillis = GiraphConstants.JMAP_SLEEP_MILLIS.get(configuration);
     linesToPrint = GiraphConstants.JMAP_PRINT_LINES.get(configuration);
+    liveObjectsOnly = GiraphConstants.JMAP_LIVE_ONLY.get(configuration);
   }
 
   @Override


Mime
View raw message