From 7320f9bd190afb7639cd21e956e7300fdd84c0ee Mon Sep 17 00:00:00 2001 From: Shixiong Zhu Date: Tue, 29 Mar 2016 21:14:48 -0700 Subject: [PATCH] [SPARK-14254][CORE] Add logs to help investigate the network performance ## What changes were proposed in this pull request? It would be very helpful for network performance investigation if we log the time spent on connecting and resolving host. ## How was this patch tested? Jenkins unit tests. Author: Shixiong Zhu Closes #12046 from zsxwing/connection-time. --- .../apache/spark/network/client/TransportClientFactory.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/network-common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java b/common/network-common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java index f179bad1f4..5a36e18b09 100644 --- a/common/network-common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java +++ b/common/network-common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java @@ -123,7 +123,10 @@ public class TransportClientFactory implements Closeable { public TransportClient createClient(String remoteHost, int remotePort) throws IOException { // Get connection from the connection pool first. // If it is not found or not active, create a new one. + long preResolveHost = System.nanoTime(); final InetSocketAddress address = new InetSocketAddress(remoteHost, remotePort); + long hostResolveTimeMs = (System.nanoTime() - preResolveHost) / 1000000; + logger.info("Spent {} ms to resolve {}", hostResolveTimeMs, address); // Create the ClientPool if we don't have it yet. ClientPool clientPool = connectionPool.get(address); @@ -235,7 +238,7 @@ public class TransportClientFactory implements Closeable { } long postBootstrap = System.nanoTime(); - logger.debug("Successfully created connection to {} after {} ms ({} ms spent in bootstraps)", + logger.info("Successfully created connection to {} after {} ms ({} ms spent in bootstraps)", address, (postBootstrap - preConnect) / 1000000, (postBootstrap - preBootstrap) / 1000000); return client;