You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ac...@apache.org on 2012/09/27 10:23:46 UTC

svn commit: r1390885 - in /giraph/trunk: ./ src/main/java/org/apache/giraph/comm/netty/ src/main/java/org/apache/giraph/comm/netty/handler/ src/main/java/org/apache/giraph/graph/ src/main/java/org/apache/giraph/utils/ src/test/java/org/apache/giraph/ s...

Author: aching
Date: Thu Sep 27 08:23:45 2012
New Revision: 1390885

URL: http://svn.apache.org/viewvc?rev=1390885&view=rev
Log:
GIRAPH-341: Improved log messages (timing) and upgraded junit to 4.8
for better tests.

Added:
    giraph/trunk/src/test/java/org/apache/giraph/utils/BspUtilsTest.java
Modified:
    giraph/trunk/CHANGELOG
    giraph/trunk/pom.xml
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/ByteCounter.java
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/NettyWorkerClient.java
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestDecoder.java
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestEncoder.java
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestInfo.java
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestServerHandler.java
    giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/ResponseClientHandler.java
    giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceMaster.java
    giraph/trunk/src/main/java/org/apache/giraph/graph/GraphMapper.java
    giraph/trunk/src/main/java/org/apache/giraph/utils/FakeTime.java
    giraph/trunk/src/main/java/org/apache/giraph/utils/SystemTime.java
    giraph/trunk/src/main/java/org/apache/giraph/utils/Time.java
    giraph/trunk/src/test/java/org/apache/giraph/TestBspBasic.java
    giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestDoubleAggregators.java
    giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java
    giraph/trunk/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java
    giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java

Modified: giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/giraph/trunk/CHANGELOG?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/CHANGELOG (original)
+++ giraph/trunk/CHANGELOG Thu Sep 27 08:23:45 2012
@@ -1,6 +1,9 @@
 Giraph Change Log
 
 Release 0.2.0 - unreleased
+
+  GIRAPH-341: Improved log messages (timing) and upgraded junit to 4.8
+  for better tests. (aching)
   
   GIRAPH-343: Use published hcatalog jars. (nitayj via aching)
 

Modified: giraph/trunk/pom.xml
URL: http://svn.apache.org/viewvc/giraph/trunk/pom.xml?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/pom.xml (original)
+++ giraph/trunk/pom.xml Thu Sep 27 08:23:45 2012
@@ -857,7 +857,7 @@ under the License.
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.0</version>
+      <version>4.8</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/ByteCounter.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/ByteCounter.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/ByteCounter.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/ByteCounter.java Thu Sep 27 08:23:45 2012
@@ -20,6 +20,7 @@ package org.apache.giraph.comm.netty;
 
 import java.text.DecimalFormat;
 import java.util.concurrent.atomic.AtomicLong;
+import org.apache.log4j.Logger;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.channel.ChannelEvent;
 import org.jboss.netty.channel.ChannelHandlerContext;
@@ -36,6 +37,9 @@ public class ByteCounter extends SimpleC
   /** Helper to format the doubles */
   private static final DecimalFormat DOUBLE_FORMAT =
       new DecimalFormat("#######.####");
+  /** Class logger */
+  private static final Logger LOG =
+      Logger.getLogger(ByteCounter.class);
   /** All bytes ever sent */
   private final AtomicLong bytesSent = new AtomicLong();
   /** Total sent requests */
@@ -56,6 +60,10 @@ public class ByteCounter extends SimpleC
       ChannelBuffer b = (ChannelBuffer) ((MessageEvent) e).getMessage();
       bytesReceived.addAndGet(b.readableBytes());
       receivedRequests.incrementAndGet();
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("handleUpstream: " + ctx.getName() + " buffer size = " +
+            b.readableBytes() + ", total bytes = " + bytesReceived.get());
+      }
     }
 
     super.handleUpstream(ctx, e);
@@ -69,6 +77,10 @@ public class ByteCounter extends SimpleC
       ChannelBuffer b = (ChannelBuffer) ((MessageEvent) e).getMessage();
       bytesSent.addAndGet(b.readableBytes());
       sentRequests.incrementAndGet();
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("handleDownstream: " + ctx.getName() + " buffer size = " +
+            b.readableBytes() + ", total bytes = " + bytesSent.get());
+      }
     }
 
     super.handleDownstream(ctx, e);
@@ -141,9 +153,9 @@ public class ByteCounter extends SimpleC
         DOUBLE_FORMAT.format(getMbytesPerSecReceived()) +
         ", MBytesSent = " + DOUBLE_FORMAT.format(mBytesSent) +
         ", MBytesReceived = " + DOUBLE_FORMAT.format(mBytesReceived) +
-        ", ave sent request MBytes = " +
+        ", ave sent req MBytes = " +
         DOUBLE_FORMAT.format(mBytesSentPerReq) +
-        ", ave received request MBytes = " +
+        ", ave received req MBytes = " +
         DOUBLE_FORMAT.format(mBytesReceivedPerReq) +
         ", secs waited = " +
         ((System.currentTimeMillis() - startMsecs.get()) / 1000f);

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/NettyWorkerClient.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/NettyWorkerClient.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/NettyWorkerClient.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/NettyWorkerClient.java Thu Sep 27 08:23:45 2012
@@ -232,8 +232,8 @@ public class NettyWorkerClient<I extends
     PartitionOwner partitionOwner =
         service.getVertexPartitionOwner(destVertexId);
     int partitionId = partitionOwner.getPartitionId();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("sendMessageRequest: Send bytes (" + message.toString() +
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("sendMessageRequest: Send bytes (" + message.toString() +
           ") to " + destVertexId + " with partition " + partitionId);
     }
     ++totalMsgsSentInSuperstep;
@@ -261,8 +261,9 @@ public class NettyWorkerClient<I extends
                                    Partition<I, V, E, M> partition) {
     InetSocketAddress remoteServerAddress =
         getInetSocketAddress(workerInfo, partition.getId());
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("sendPartitionRequest: Sending to " + remoteServerAddress +
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("sendPartitionRequest: Sending to " +
+          remoteServerAddress +
           " from " + workerInfo + ", with partition " + partition);
     }
 
@@ -333,8 +334,8 @@ public class NettyWorkerClient<I extends
     PartitionOwner partitionOwner =
         service.getVertexPartitionOwner(vertexIndex);
     int partitionId = partitionOwner.getPartitionId();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("addEdgeRequest: Sending edge " + edge + " for index " +
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("addEdgeRequest: Sending edge " + edge + " for index " +
           vertexIndex + " with partition " + partitionId);
     }
 
@@ -352,8 +353,9 @@ public class NettyWorkerClient<I extends
     PartitionOwner partitionOwner =
         service.getVertexPartitionOwner(vertexIndex);
     int partitionId = partitionOwner.getPartitionId();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("removeEdgeRequest: Removing edge " + destinationVertexIndex +
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("removeEdgeRequest: Removing edge " +
+          destinationVertexIndex +
           " for index " + vertexIndex + " with partition " + partitionId);
     }
 
@@ -371,8 +373,8 @@ public class NettyWorkerClient<I extends
     PartitionOwner partitionOwner =
         service.getVertexPartitionOwner(vertex.getId());
     int partitionId = partitionOwner.getPartitionId();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("addVertexRequest: Sending vertex " + vertex +
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("addVertexRequest: Sending vertex " + vertex +
           " to partition " + partitionId);
     }
 
@@ -389,9 +391,9 @@ public class NettyWorkerClient<I extends
     PartitionOwner partitionOwner =
         service.getVertexPartitionOwner(vertexIndex);
     int partitionId = partitionOwner.getPartitionId();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("removeVertexRequest: Removing vertex index " + vertexIndex +
-          " from partition " + partitionId);
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("removeVertexRequest: Removing vertex index " +
+          vertexIndex + " from partition " + partitionId);
     }
 
     // Add the message to the cache

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestDecoder.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestDecoder.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestDecoder.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestDecoder.java Thu Sep 27 08:23:45 2012
@@ -24,6 +24,7 @@ import org.apache.giraph.comm.requests.R
 import org.apache.giraph.comm.requests.WritableRequest;
 import org.apache.giraph.utils.ReflectionUtils;
 
+import org.apache.giraph.utils.SystemTime;
 import org.apache.log4j.Logger;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBufferInputStream;
@@ -42,7 +43,8 @@ public class RequestDecoder extends OneT
   private final ImmutableClassesGiraphConfiguration conf;
   /** Byte counter to output */
   private final ByteCounter byteCounter;
-
+  /** Start nanoseconds for the decoding time */
+  private long startDecodingNanoseconds = -1;
   /**
    * Constructor.
    *
@@ -70,18 +72,30 @@ public class RequestDecoder extends OneT
       }
     }
 
+    if (LOG.isDebugEnabled()) {
+      startDecodingNanoseconds = SystemTime.getInstance().getNanoseconds();
+    }
+
+    // Decode the request
     ChannelBuffer buffer = (ChannelBuffer) msg;
     ChannelBufferInputStream inputStream = new ChannelBufferInputStream(buffer);
     int enumValue = inputStream.readByte();
     RequestType type = RequestType.values()[enumValue];
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("decode: Got a request of type " + type);
-    }
     Class<? extends WritableRequest> writableRequestClass =
         type.getRequestClass();
+
     WritableRequest writableRequest =
         ReflectionUtils.newInstance(writableRequestClass, conf);
     writableRequest.readFields(inputStream);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("decode: Client " + writableRequest.getClientId() +
+          ", requestId " + writableRequest.getRequestId() +
+          ", " +  writableRequest.getType() + ", with size " +
+          buffer.array().length + " took " +
+          SystemTime.getInstance().getNanosecondsSince(
+              startDecodingNanoseconds) + " ns");
+    }
+
     return writableRequest;
   }
 }

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestEncoder.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestEncoder.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestEncoder.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestEncoder.java Thu Sep 27 08:23:45 2012
@@ -19,6 +19,8 @@
 package org.apache.giraph.comm.netty.handler;
 
 import org.apache.giraph.comm.requests.WritableRequest;
+import org.apache.giraph.utils.SystemTime;
+
 import org.apache.log4j.Logger;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBufferOutputStream;
@@ -32,11 +34,14 @@ import org.jboss.netty.handler.codec.one
  */
 public class RequestEncoder extends OneToOneEncoder {
   /** Class logger */
-  private static final Logger LOG = Logger.getLogger(RequestEncoder.class);
+  private static final Logger LOG =
+      Logger.getLogger(RequestEncoder.class);
   /** Holds the place of the message length until known */
   private static final byte[] LENGTH_PLACEHOLDER = new byte[4];
   /** Buffer starting size */
   private final int bufferStartingSize;
+  /** Start nanoseconds for the encoding time */
+  private long startEncodingNanoseconds = -1;
 
   /**
    * Constructor.
@@ -55,6 +60,10 @@ public class RequestEncoder extends OneT
           "encode: Got a message of type " + msg.getClass());
     }
 
+    // Encode the request
+    if (LOG.isDebugEnabled()) {
+      startEncodingNanoseconds = SystemTime.getInstance().getNanoseconds();
+    }
     WritableRequest writableRequest = (WritableRequest) msg;
     ChannelBufferOutputStream outputStream =
         new ChannelBufferOutputStream(ChannelBuffers.dynamicBuffer(
@@ -65,13 +74,18 @@ public class RequestEncoder extends OneT
     writableRequest.write(outputStream);
     outputStream.flush();
     outputStream.close();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("encode: Encoding a message of type " + msg.getClass());
-    }
 
     // Set the correct size at the end
     ChannelBuffer encodedBuffer = outputStream.buffer();
     encodedBuffer.setInt(0, encodedBuffer.writerIndex() - 4);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("encode: Client " + writableRequest.getClientId() + ", " +
+          "requestId " + writableRequest.getRequestId() +
+          ", size = " + encodedBuffer.writerIndex() +
+          writableRequest.getType() + " took " +
+          SystemTime.getInstance().getNanosecondsSince(
+              startEncodingNanoseconds) + " ns");
+    }
     return encodedBuffer;
   }
 }

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestInfo.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestInfo.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestInfo.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestInfo.java Thu Sep 27 08:23:45 2012
@@ -20,8 +20,9 @@ package org.apache.giraph.comm.netty.han
 
 import java.net.InetSocketAddress;
 import java.util.Date;
-
 import org.apache.giraph.comm.requests.WritableRequest;
+import org.apache.giraph.utils.SystemTime;
+import org.apache.giraph.utils.Time;
 import org.jboss.netty.channel.ChannelFuture;
 
 /**
@@ -31,7 +32,7 @@ public class RequestInfo {
   /** Destination of the request */
   private final InetSocketAddress destinationAddress;
   /** When the request was started */
-  private final long startedMsecs;
+  private final long startedNanos;
   /** Request */
   private final WritableRequest request;
   /** Future of the write of this request*/
@@ -47,26 +48,41 @@ public class RequestInfo {
                      WritableRequest request) {
     this.destinationAddress = destinationAddress;
     this.request = request;
-    this.startedMsecs = System.currentTimeMillis();
+    this.startedNanos = SystemTime.getInstance().getNanoseconds();
   }
 
   public InetSocketAddress getDestinationAddress() {
     return destinationAddress;
   }
 
+  /**
+   * Get the started msecs.
+   *
+   * @return Started msecs
+   */
   public long getStartedMsecs() {
-    return startedMsecs;
+    return startedNanos / Time.NS_PER_MS;
+  }
+
+  /**
+   * Get the elapsed nanoseconds since the request started.
+   *
+   * @return Nanoseconds since the request was started
+   */
+  public long getElapsedNanos() {
+    return SystemTime.getInstance().getNanoseconds() - startedNanos;
   }
 
   /**
-   * Get the elapsed time since the request started.
+   * Get the elapsed millseconds since the request started.
    *
-   * @return Msecs since the request was started
+   * @return Milliseconds since the request was started
    */
   public long getElapsedMsecs() {
-    return System.currentTimeMillis() - startedMsecs;
+    return getElapsedNanos() / Time.NS_PER_MS;
   }
 
+
   public WritableRequest getRequest() {
     return request;
   }
@@ -81,9 +97,12 @@ public class RequestInfo {
 
   @Override
   public String toString() {
-    return "(destAddr=" + destinationAddress +
-        ",startDate=" + new Date(startedMsecs) + ",elapsedMsecs=" +
-        getElapsedMsecs() + ",reqId=" + request.getRequestId() +
+    return "(reqId=" + request.getRequestId() +
+        ",destAddr=" + destinationAddress.getHostName() + ":" +
+        destinationAddress.getPort() +
+        ",elapsedNanos=" +
+        getElapsedNanos() +
+        ",started=" + new Date(getStartedMsecs()) +
         ((writeFuture == null) ? ")" :
             ",writeDone=" + writeFuture.isDone() +
                 ",writeSuccess=" + writeFuture.isSuccess() + ")");

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestServerHandler.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestServerHandler.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestServerHandler.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/RequestServerHandler.java Thu Sep 27 08:23:45 2012
@@ -20,6 +20,7 @@ package org.apache.giraph.comm.netty.han
 
 import org.apache.giraph.GiraphConfiguration;
 import org.apache.giraph.comm.requests.WritableRequest;
+import org.apache.giraph.utils.SystemTime;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.log4j.Logger;
 import org.jboss.netty.buffer.ChannelBuffer;
@@ -50,6 +51,8 @@ public abstract class RequestServerHandl
   private final WorkerRequestReservedMap workerRequestReservedMap;
   /** My worker id */
   private final int myWorkerId;
+  /** Start nanoseconds for the processing time */
+  private long startProcessingNanoseconds = -1;
 
   /**
    * Constructor
@@ -70,8 +73,8 @@ public abstract class RequestServerHandl
   @Override
   public void messageReceived(
       ChannelHandlerContext ctx, MessageEvent e) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("messageReceived: Got " + e.getMessage().getClass());
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("messageReceived: Got " + e.getMessage().getClass());
     }
 
     WritableRequest writableRequest = (WritableRequest) e.getMessage();
@@ -91,7 +94,18 @@ public abstract class RequestServerHandl
     if (workerRequestReservedMap.reserveRequest(
         writableRequest.getClientId(),
         writableRequest.getRequestId())) {
+      if (LOG.isDebugEnabled()) {
+        startProcessingNanoseconds = SystemTime.getInstance().getNanoseconds();
+      }
       processRequest((R) writableRequest);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("messageReceived: Processing client " +
+            writableRequest.getClientId() + ", " +
+            "requestId " + writableRequest.getRequestId() +
+            ", " +  writableRequest.getType() + " took " +
+            SystemTime.getInstance().getNanosecondsSince(
+                startProcessingNanoseconds) + " ns");
+      }
       alreadyDone = 0;
     } else {
       LOG.info("messageReceived: Request id " +

Modified: giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/ResponseClientHandler.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/ResponseClientHandler.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/ResponseClientHandler.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/comm/netty/handler/ResponseClientHandler.java Thu Sep 27 08:23:45 2012
@@ -112,10 +112,9 @@ public class ResponseClientHandler exten
           requestId);
     } else {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("messageReceived: Processed request id = " + requestId +
-            " " + requestInfo + ".  Waiting on " +
-            workerIdOutstandingRequestMap.size() +
-            " requests, bytes = " + buffer.capacity());
+        LOG.debug("messageReceived: Completed " + requestInfo +
+            ".  Waiting on " + workerIdOutstandingRequestMap.size() +
+            " requests");
       }
     }
 

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceMaster.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceMaster.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceMaster.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceMaster.java Thu Sep 27 08:23:45 2012
@@ -1757,7 +1757,8 @@ public class BspServiceMaster<I extends 
         if (LOG.isInfoEnabled()) {
           LOG.info("cleanup: Removed HDFS checkpoint directory (" +
               checkpointBasePath + ") with return = " +
-              success + " since this job succeeded ");
+              success + " since the job " + getContext().getJobName() +
+              " succeeded ");
         }
       }
       aggregatorWriter.close();

Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/GraphMapper.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/GraphMapper.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/graph/GraphMapper.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/graph/GraphMapper.java Thu Sep 27 08:23:45 2012
@@ -307,7 +307,8 @@ public class GraphMapper<I extends Writa
       }
 
       if (LOG.isInfoEnabled()) {
-        LOG.info("setup: classpath @ " + zkClasspath);
+        LOG.info("setup: classpath @ " + zkClasspath + " for job " +
+            context.getJobName());
       }
       context.getConfiguration().set(
           GiraphConfiguration.ZOOKEEPER_JAR, zkClasspath);

Modified: giraph/trunk/src/main/java/org/apache/giraph/utils/FakeTime.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/utils/FakeTime.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/utils/FakeTime.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/utils/FakeTime.java Thu Sep 27 08:23:45 2012
@@ -35,16 +35,31 @@ public class FakeTime implements Time {
   }
 
   @Override
+  public long getMillisecondsSince(long previousMilliseconds) {
+    return getMilliseconds() - previousMilliseconds;
+  }
+
+  @Override
   public long getNanoseconds() {
     return nanosecondsSinceEpoch.get();
   }
 
   @Override
+  public long getNanosecondsSince(long previousNanoseconds) {
+    return getNanoseconds() - previousNanoseconds;
+  }
+
+  @Override
   public int getSeconds() {
     return (int) (nanosecondsSinceEpoch.get() / NS_PER_SECOND);
   }
 
   @Override
+  public int getSecondsSince(int previousSeconds) {
+    return getSeconds() - previousSeconds;
+  }
+
+  @Override
   public Date getCurrentDate() {
     return new Date(getMilliseconds());
   }

Modified: giraph/trunk/src/main/java/org/apache/giraph/utils/SystemTime.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/utils/SystemTime.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/utils/SystemTime.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/utils/SystemTime.java Thu Sep 27 08:23:45 2012
@@ -36,16 +36,32 @@ public class SystemTime implements Time 
   }
 
   @Override
+  public long getMillisecondsSince(long previousMilliseconds) {
+    return getMilliseconds() - previousMilliseconds;
+  }
+
+
+  @Override
   public long getNanoseconds() {
     return System.nanoTime();
   }
 
   @Override
+  public long getNanosecondsSince(long previousNanoseconds) {
+    return getNanoseconds() - previousNanoseconds;
+  }
+
+  @Override
   public int getSeconds() {
     return (int) (getMilliseconds() / MS_PER_SECOND);
   }
 
   @Override
+  public int getSecondsSince(int previousSeconds) {
+    return getSeconds() - previousSeconds;
+  }
+
+  @Override
   public Date getCurrentDate() {
     return new Date();
   }

Modified: giraph/trunk/src/main/java/org/apache/giraph/utils/Time.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/utils/Time.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/main/java/org/apache/giraph/utils/Time.java (original)
+++ giraph/trunk/src/main/java/org/apache/giraph/utils/Time.java Thu Sep 27 08:23:45 2012
@@ -56,6 +56,15 @@ public interface Time {
   long getMilliseconds();
 
   /**
+   * Convenience method to get milliseconds since a previous milliseconds
+   * point.
+   *
+   * @param previousMilliseconds Previous milliseconds
+   * @return Milliseconds elapsed since the previous milliseconds
+   */
+  long getMillisecondsSince(long previousMilliseconds);
+
+  /**
    * Get the current nanoseconds
    *
    * @return The difference, measured in nanoseconds, between
@@ -64,6 +73,15 @@ public interface Time {
   long getNanoseconds();
 
   /**
+   * Convenience method to get nanoseconds since a previous nanoseconds
+   * point.
+   *
+   * @param previousNanoseconds Previous nanoseconds
+   * @return Nanoseconds elapsed since the previous nanoseconds
+   */
+  long getNanosecondsSince(long previousNanoseconds);
+
+  /**
    * Get the current seconds
    *
    * @return The difference, measured in seconds, between
@@ -72,6 +90,15 @@ public interface Time {
   int getSeconds();
 
   /**
+   * Convenience method to get seconds since a previous seconds
+   * point.
+   *
+   * @param previousSeconds Previous seconds
+   * @return Seconds elapsed since the previous seconds
+   */
+  int getSecondsSince(int previousSeconds);
+
+  /**
    * Get the current date
    *
    * @return Current date
@@ -79,7 +106,7 @@ public interface Time {
   Date getCurrentDate();
 
   /**
-   * Current thread should sleep for some number of milliseconds
+   * Current thread should sleep for some number of milliseconds.
    *
    * @param milliseconds Milliseconds to sleep for
    * @throws InterruptedException

Modified: giraph/trunk/src/test/java/org/apache/giraph/TestBspBasic.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/TestBspBasic.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/TestBspBasic.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/TestBspBasic.java Thu Sep 27 08:23:45 2012
@@ -65,6 +65,7 @@ import static org.junit.Assert.assertSam
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -490,9 +491,9 @@ public class TestBspBasic extends BspCas
           assertEquals(maxSuperstep + 2, maxValues.size());
           assertEquals(maxSuperstep + 2, vertexCounts.size());
 
-          assertEquals(maxPageRank, maxValues.get(maxSuperstep));
-          assertEquals(minPageRank, minValues.get(maxSuperstep));
-          assertEquals(numVertices, vertexCounts.get(maxSuperstep));
+          assertEquals(maxPageRank, (double) maxValues.get(maxSuperstep), 0d);
+          assertEquals(minPageRank, (double) minValues.get(maxSuperstep), 0d);
+          assertEquals(numVertices, (long) vertexCounts.get(maxSuperstep));
 
         } finally {
           Closeables.closeQuietly(in);
@@ -525,7 +526,7 @@ public class TestBspBasic extends BspCas
       double finalSum =
           SimpleMasterComputeVertex.SimpleMasterComputeWorkerContext.getFinalSum();
       System.out.println("testBspMasterCompute: finalSum=" + finalSum);
-      assertEquals(32.5, finalSum);
+      assertEquals(32.5, finalSum, 0d);
     }
   }
 }

Modified: giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestDoubleAggregators.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestDoubleAggregators.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestDoubleAggregators.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestDoubleAggregators.java Thu Sep 27 08:23:45 2012
@@ -30,9 +30,9 @@ public class TestDoubleAggregators {
     DoubleMaxAggregator max = new DoubleMaxAggregator();
     max.aggregate(new DoubleWritable(2.0));
     max.aggregate(new DoubleWritable(3.0));
-    assertEquals(3.0, max.getAggregatedValue().get());
+    assertEquals(3.0, max.getAggregatedValue().get(), 0d);
     max.setAggregatedValue(new DoubleWritable(1.0));
-    assertEquals(1.0, max.getAggregatedValue().get());
+    assertEquals(1.0, max.getAggregatedValue().get(), 0d);
     DoubleWritable dw = max.createInitialValue();
     assertNotNull(dw);
   }
@@ -42,9 +42,9 @@ public class TestDoubleAggregators {
     DoubleMinAggregator min = new DoubleMinAggregator();
     min.aggregate(new DoubleWritable(3.0));
     min.aggregate(new DoubleWritable(2.0));
-    assertEquals(2.0, min.getAggregatedValue().get());
+    assertEquals(2.0, min.getAggregatedValue().get(), 0d);
     min.setAggregatedValue(new DoubleWritable(3.0));
-    assertEquals(3.0, min.getAggregatedValue().get());
+    assertEquals(3.0, min.getAggregatedValue().get(), 0d);
     DoubleWritable dw = min.createInitialValue();
     assertNotNull(dw);
   }
@@ -53,11 +53,11 @@ public class TestDoubleAggregators {
   public void testOverwriteAggregator() {
     DoubleOverwriteAggregator overwrite = new DoubleOverwriteAggregator();
     overwrite.aggregate(new DoubleWritable(1.0));
-    assertEquals(1.0, overwrite.getAggregatedValue().get());
+    assertEquals(1.0, overwrite.getAggregatedValue().get(), 0d);
     overwrite.aggregate(new DoubleWritable(2.0));
-    assertEquals(2.0, overwrite.getAggregatedValue().get());
+    assertEquals(2.0, overwrite.getAggregatedValue().get(), 0d);
     overwrite.setAggregatedValue(new DoubleWritable(3.0));
-    assertEquals(3.0, overwrite.getAggregatedValue().get());
+    assertEquals(3.0, overwrite.getAggregatedValue().get(), 0d);
     DoubleWritable dw = overwrite.createInitialValue();
     assertNotNull(dw);
   }
@@ -67,9 +67,9 @@ public class TestDoubleAggregators {
     DoubleProductAggregator product = new DoubleProductAggregator();
     product.aggregate(new DoubleWritable(6.0));
     product.aggregate(new DoubleWritable(7.0));
-    assertEquals(42.0, product.getAggregatedValue().get());
+    assertEquals(42.0, product.getAggregatedValue().get(), 0d);
     product.setAggregatedValue(new DoubleWritable(1.0));
-    assertEquals(1.0, product.getAggregatedValue().get());
+    assertEquals(1.0, product.getAggregatedValue().get(), 0d);
     DoubleWritable dw = product.createInitialValue();
     assertNotNull(dw);
   }
@@ -79,9 +79,9 @@ public class TestDoubleAggregators {
     DoubleSumAggregator sum = new DoubleSumAggregator();
     sum.aggregate(new DoubleWritable(1.0));
     sum.aggregate(new DoubleWritable(2.0));
-    assertEquals(3.0, sum.getAggregatedValue().get());
+    assertEquals(3.0, sum.getAggregatedValue().get(), 0d);
     sum.setAggregatedValue(new DoubleWritable(4.0));
-    assertEquals(4.0, sum.getAggregatedValue().get());
+    assertEquals(4.0, sum.getAggregatedValue().get(), 0d);
     DoubleWritable dw = sum.createInitialValue();
     assertNotNull(dw);
   }

Modified: giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java Thu Sep 27 08:23:45 2012
@@ -30,9 +30,9 @@ public class TestFloatAggregators {
     FloatMaxAggregator max = new FloatMaxAggregator();
     max.aggregate(new FloatWritable(2.0f));
     max.aggregate(new FloatWritable(3.0f));
-    assertEquals(3.0f, max.getAggregatedValue().get());
+    assertEquals(3.0f, max.getAggregatedValue().get(), 0f);
     max.setAggregatedValue(new FloatWritable(1.0f));
-    assertEquals(1.0f, max.getAggregatedValue().get());
+    assertEquals(1.0f, max.getAggregatedValue().get(), 0f);
     FloatWritable fw = max.createInitialValue();
     assertNotNull(fw);
   }
@@ -42,9 +42,9 @@ public class TestFloatAggregators {
     FloatMinAggregator min = new FloatMinAggregator();
     min.aggregate(new FloatWritable(3.0f));
     min.aggregate(new FloatWritable(2.0f));
-    assertEquals(2.0f, min.getAggregatedValue().get());
+    assertEquals(2.0f, min.getAggregatedValue().get(), 0f);
     min.setAggregatedValue(new FloatWritable(3.0f));
-    assertEquals(3.0f, min.getAggregatedValue().get());
+    assertEquals(3.0f, min.getAggregatedValue().get(), 0f);
     FloatWritable fw = min.createInitialValue();
     assertNotNull(fw);
   }
@@ -53,11 +53,11 @@ public class TestFloatAggregators {
   public void testOverwriteAggregator() {
     FloatOverwriteAggregator overwrite = new FloatOverwriteAggregator();
     overwrite.aggregate(new FloatWritable(1.0f));
-    assertEquals(1.0f, overwrite.getAggregatedValue().get());
+    assertEquals(1.0f, overwrite.getAggregatedValue().get(), 0f);
     overwrite.aggregate(new FloatWritable(2.0f));
-    assertEquals(2.0f, overwrite.getAggregatedValue().get());
+    assertEquals(2.0f, overwrite.getAggregatedValue().get(), 0f);
     overwrite.setAggregatedValue(new FloatWritable(3.0f));
-    assertEquals(3.0f, overwrite.getAggregatedValue().get());
+    assertEquals(3.0f, overwrite.getAggregatedValue().get(), 0f);
     FloatWritable fw = overwrite.createInitialValue();
     assertNotNull(fw);
   }
@@ -67,9 +67,9 @@ public class TestFloatAggregators {
     FloatProductAggregator product = new FloatProductAggregator();
     product.aggregate(new FloatWritable(6.0f));
     product.aggregate(new FloatWritable(7.0f));
-    assertEquals(42.0f, product.getAggregatedValue().get());
+    assertEquals(42.0f, product.getAggregatedValue().get(), 0f);
     product.setAggregatedValue(new FloatWritable(1.0f));
-    assertEquals(1.0f, product.getAggregatedValue().get());
+    assertEquals(1.0f, product.getAggregatedValue().get(), 0f);
     FloatWritable fw = product.createInitialValue();
     assertNotNull(fw);
   }
@@ -79,11 +79,10 @@ public class TestFloatAggregators {
     FloatSumAggregator sum = new FloatSumAggregator();
     sum.aggregate(new FloatWritable(1.0f));
     sum.aggregate(new FloatWritable(2.0f));
-    assertEquals(3.0f, sum.getAggregatedValue().get());
+    assertEquals(3.0f, sum.getAggregatedValue().get(), 0f);
     sum.setAggregatedValue(new FloatWritable(4.0f));
-    assertEquals(4.0f, sum.getAggregatedValue().get());
+    assertEquals(4.0f, sum.getAggregatedValue().get(), 0f);
     FloatWritable fw = sum.createInitialValue();
     assertNotNull(fw);
   }
-
 }

Modified: giraph/trunk/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java Thu Sep 27 08:23:45 2012
@@ -69,7 +69,7 @@ public class SimpleShortestPathsVertexTe
         new DoubleWritable(1.5)));
 
     assertTrue(vertex.isHalted());
-    assertEquals(1.5, vertex.getValue().get());
+    assertEquals(1.5d, vertex.getValue().get(), 0d);
 
     env.verifyMessageSent(new LongWritable(10L), new DoubleWritable(4));
     env.verifyMessageSent(new LongWritable(20L), new DoubleWritable(2));
@@ -99,7 +99,7 @@ public class SimpleShortestPathsVertexTe
         new DoubleWritable(1.5)));
 
     assertTrue(vertex.isHalted());
-    assertEquals(0.5, vertex.getValue().get());
+    assertEquals(0.5d, vertex.getValue().get(), 0d);
 
     env.verifyNoMessageSent();
   }
@@ -133,11 +133,11 @@ public class SimpleShortestPathsVertexTe
 
     // verify results
     assertNotNull(distances);
-    assertEquals(4, distances.size());
-    assertEquals(0.0, distances.get(1L));
-    assertEquals(1.0, distances.get(2L));
-    assertEquals(2.0, distances.get(3L));
-    assertEquals(4.0, distances.get(4L));
+    assertEquals(4, (int) distances.size());
+    assertEquals(0.0, (double) distances.get(1L), 0d);
+    assertEquals(1.0, (double) distances.get(2L), 0d);
+    assertEquals(2.0, (double) distances.get(3L), 0d);
+    assertEquals(4.0, (double) distances.get(4L), 0d);
   }
 
   private Map<Long, Double> parseDistances(Iterable<String> results) {

Modified: giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java?rev=1390885&r1=1390884&r2=1390885&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java Thu Sep 27 08:23:45 2012
@@ -19,6 +19,8 @@ package org.apache.giraph.graph;
 
 import org.apache.giraph.GiraphConfiguration;
 import org.apache.giraph.ImmutableClassesGiraphConfiguration;
+import org.apache.giraph.utils.SystemTime;
+import org.apache.giraph.utils.Time;
 import org.apache.giraph.utils.WritableUtils;
 import org.apache.giraph.graph.partition.PartitionOwner;
 import org.apache.hadoop.conf.Configuration;
@@ -109,7 +111,7 @@ public class TestEdgeListVertex {
     assertEquals(vertex.getNumEdges(), 1000);
     for (Edge<IntWritable, DoubleWritable> edge : vertex.getEdges()) {
       assertEquals(edge.getValue().get(),
-          edge.getTargetVertexId().get() * 2.0d);
+          edge.getTargetVertexId().get() * 2.0d, 0d);
     }
     assertEquals(vertex.removeEdge(new IntWritable(500)),
         new DoubleWritable(1000));
@@ -155,7 +157,8 @@ public class TestEdgeListVertex {
     assertNull(vertex.getEdgeValue(new IntWritable(5)));
     assertNull(vertex.getEdgeValue(new IntWritable(0)));
     for (Edge<IntWritable, DoubleWritable> edge : vertex.getEdges()) {
-      assertEquals(edge.getTargetVertexId().get() * 1.0d, edge.getValue().get());
+      assertEquals(edge.getTargetVertexId().get() * 1.0d,
+          edge.getValue().get(), 0d);
     }
     assertNotNull(vertex.removeEdge(new IntWritable(1)));
     assertEquals(vertex.getNumEdges(), 3);
@@ -199,10 +202,26 @@ public class TestEdgeListVertex {
     messageList.add(new LongWritable(5));
     vertex.initialize(
         new IntWritable(2), new FloatWritable(3.0f), edgeMap, messageList);
+    long serializeNanosStart = SystemTime.getInstance().getNanoseconds();
     byte[] byteArray = WritableUtils.writeToByteArray(vertex);
+    long serializeNanos = SystemTime.getInstance().getNanosecondsSince(
+        serializeNanosStart);
+    System.out.println("testSerialize: Serializing took " +
+        serializeNanos +
+        " ns for " + byteArray.length + " bytes " +
+        (byteArray.length * 1f * Time.NS_PER_SECOND / serializeNanos) +
+        " bytes / sec");
     IFDLEdgeListVertex readVertex = (IFDLEdgeListVertex)
       configuration.createVertex();
+    long deserializeNanosStart = SystemTime.getInstance().getNanoseconds();
     WritableUtils.readFieldsFromByteArray(byteArray, readVertex);
+    long deserializeNanos = SystemTime.getInstance().getNanosecondsSince(
+        deserializeNanosStart);
+    System.out.println("testSerialize: Deserializing took " +
+        deserializeNanos +
+        " ns for " + byteArray.length + " bytes " +
+        (byteArray.length * 1f * Time.NS_PER_SECOND / deserializeNanos) +
+        " bytes / sec");
 
     assertEquals(vertex.getId(), readVertex.getId());
     assertEquals(vertex.getValue(), readVertex.getValue());

Added: giraph/trunk/src/test/java/org/apache/giraph/utils/BspUtilsTest.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/utils/BspUtilsTest.java?rev=1390885&view=auto
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/utils/BspUtilsTest.java (added)
+++ giraph/trunk/src/test/java/org/apache/giraph/utils/BspUtilsTest.java Thu Sep 27 08:23:45 2012
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.utils;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.apache.giraph.GiraphConfiguration;
+import org.apache.giraph.ImmutableClassesGiraphConfiguration;
+import org.apache.giraph.graph.BspUtils;
+import org.apache.giraph.graph.EdgeListVertex;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Benchmark tests to insure that object creation is fast
+ */
+public class BspUtilsTest {
+  @Rule
+  public TestName name = new TestName();
+  private static final long COUNT = 200000;
+  private Configuration conf = new Configuration();
+  private long startNanos = -1;
+  private long totalNanos = -1;
+  private long total = 0;
+  private long expected = COUNT * (COUNT - 1) / 2L;
+  private ImmutableClassesGiraphConfiguration<LongWritable, LongWritable,
+      LongWritable, LongWritable> configuration;
+
+  @Before
+  public void setUp() {
+    conf.setClass(GiraphConfiguration.VERTEX_ID_CLASS, IntWritable.class,
+        WritableComparable.class);
+    conf.setClass(GiraphConfiguration.VERTEX_VALUE_CLASS, LongWritable.class,
+        Writable.class);
+    conf.setClass(GiraphConfiguration.EDGE_VALUE_CLASS, DoubleWritable.class,
+        Writable.class);
+    conf.setClass(GiraphConfiguration.MESSAGE_VALUE_CLASS, LongWritable.class,
+        Writable.class);
+    GiraphConfiguration conf = new GiraphConfiguration();
+    conf.setVertexClass(ImmutableVertex.class);
+    configuration =
+        new ImmutableClassesGiraphConfiguration<LongWritable, LongWritable,
+            LongWritable, LongWritable>(conf);
+    total = 0;
+    System.gc();
+  }
+
+  @After
+  public void cleanUp() {
+    totalNanos = SystemTime.getInstance().getNanosecondsSince(startNanos);
+    System.out.println(name.getMethodName() + ": took "
+        + totalNanos +
+        " ns for " + COUNT + " elements " + (totalNanos * 1f / COUNT) +
+        " ns / element");
+    assertEquals(expected, total);
+    System.gc();
+  }
+
+  @Test
+  public void testCreateClass() {
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = BspUtils.createVertexValue(conf);
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  @Test
+  public void testNativeCreateClass() {
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = new LongWritable();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  private Class<?> getLongWritableClass() {
+    return LongWritable.class;
+  }
+
+  @Test
+  public void testNewInstance()
+      throws IllegalAccessException, InstantiationException {
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable)
+          getLongWritableClass().newInstance();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  private synchronized Class<?> getSyncLongWritableClass() {
+    return LongWritable.class;
+  }
+
+  @Test
+  public void testSyncNewInstance()
+      throws IllegalAccessException, InstantiationException {
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable)
+          getSyncLongWritableClass().newInstance();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  @Test
+  public void testReflectionUtilsNewInstance()
+      throws IllegalAccessException, InstantiationException {
+    // Throwaway to put into cache
+    org.apache.hadoop.util.ReflectionUtils.newInstance(LongWritable.class,
+        null);
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable)
+          org.apache.hadoop.util.ReflectionUtils.newInstance(
+              getLongWritableClass(), null);
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  @Test
+  public void testConstructorNewInstance()
+      throws IllegalAccessException, InstantiationException,
+      NoSuchMethodException, InvocationTargetException {
+    Constructor<?> constructor = LongWritable.class.getDeclaredConstructor
+        (new Class[]{});
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = (LongWritable) constructor.newInstance();
+      value.set(i);
+      total += value.get();
+    }
+  }
+
+  private static class ImmutableVertex extends EdgeListVertex<LongWritable,
+      LongWritable, LongWritable, LongWritable> {
+    @Override
+    public void compute(Iterable<LongWritable> messages) throws IOException {
+    }
+  }
+
+  private ImmutableClassesGiraphConfiguration<LongWritable, LongWritable,
+      LongWritable, LongWritable> getConfiguration() {
+    return configuration;
+  }
+
+  @Test
+  public void testImmutableClassesGiraphConfigurationNewInstance() {
+    startNanos = SystemTime.getInstance().getNanoseconds();
+    for (int i = 0; i < COUNT; ++i) {
+      LongWritable value = getConfiguration().createVertexValue();
+      value.set(i);
+      total += value.get();
+    }
+  }
+}