From ba6ada73acc2bce560878272c543534c21c76f22 Mon Sep 17 00:00:00 2001 From: hfutatzhanghb Date: Thu, 18 Jan 2024 11:10:05 +0800 Subject: [PATCH] HDFS-17337. RPC RESPONSE time seems not exactly accurate when using FSEditLogAsync. (#6439). Contributed by farmmamba. Reviewed-by: Tao Li Signed-off-by: Shuyan Zhang --- .../src/main/java/org/apache/hadoop/ipc/Server.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java index f33f5dc4a3..a49b5ec692 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java @@ -1089,7 +1089,10 @@ public final void sendResponse() throws IOException { int count = responseWaitCount.decrementAndGet(); assert count >= 0 : "response has already been sent"; if (count == 0) { + long startNanos = Time.monotonicNowNanos(); doResponse(null); + getProcessingDetails().set(Timing.RESPONSE, + Time.monotonicNowNanos() - startNanos, TimeUnit.NANOSECONDS); } } @@ -1257,14 +1260,10 @@ public Void run() throws Exception { deltaNanos -= details.get(Timing.LOCKSHARED, TimeUnit.NANOSECONDS); deltaNanos -= details.get(Timing.LOCKEXCLUSIVE, TimeUnit.NANOSECONDS); details.set(Timing.LOCKFREE, deltaNanos, TimeUnit.NANOSECONDS); - startNanos = Time.monotonicNowNanos(); setResponseFields(value, responseParams); sendResponse(); - details.setReturnStatus(responseParams.returnStatus); - deltaNanos = Time.monotonicNowNanos() - startNanos; - details.set(Timing.RESPONSE, deltaNanos, TimeUnit.NANOSECONDS); } else { LOG.debug("Deferring response for callId: {}", this.callId); }