You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by fe...@apache.org on 2024/03/06 07:18:01 UTC
(hadoop) branch HDFS-17384 updated: HDFS-17405. [FGL] Using different metric name to trace performance for FGL and Global lock (#6600)
This is an automated email from the ASF dual-hosted git repository.
ferhui pushed a commit to branch HDFS-17384
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/HDFS-17384 by this push:
new 8a97eaef5523 HDFS-17405. [FGL] Using different metric name to trace performance for FGL and Global lock (#6600)
8a97eaef5523 is described below
commit 8a97eaef552333cecc16a3565b1944e45b006919
Author: ZanderXu <za...@apache.org>
AuthorDate: Wed Mar 6 15:17:53 2024 +0800
HDFS-17405. [FGL] Using different metric name to trace performance for FGL and Global lock (#6600)
---
.../hdfs/server/namenode/FSNamesystemLock.java | 34 ++++++++++++----------
.../namenode/fgl/FineGrainedFSNamesystemLock.java | 4 +--
.../namenode/fgl/GlobalFSNamesystemLock.java | 2 +-
.../hdfs/server/namenode/TestFSNamesystemLock.java | 20 ++++++-------
4 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
index abdc80e1e81a..8bfe82eb8dfc 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java
@@ -56,7 +56,7 @@ import static org.apache.hadoop.log.LogThrottlingHelper.LogAction;
* to be true, metrics will be emitted into the FSNamesystem metrics registry
* for each operation which acquires this lock indicating how long the operation
* held the lock for. These metrics have names of the form
- * FSN(Read|Write)LockNanosOperationName, where OperationName denotes the name
+ * ${LockName}(Read|Write)LockNanosOperationName, where OperationName denotes the name
* of the operation that initiated the lock hold (this will be OTHER for certain
* uncategorized operations) and they export the hold time values in
* nanoseconds. Note that if a thread dies, metrics produced after the
@@ -67,6 +67,7 @@ import static org.apache.hadoop.log.LogThrottlingHelper.LogAction;
public class FSNamesystemLock {
@VisibleForTesting
protected ReentrantReadWriteLock coarseLock;
+ private final String lockName;
private volatile boolean metricsEnabled;
private final MutableRatesWithAggregation detailedHoldTimeMetrics;
@@ -123,23 +124,26 @@ public class FSNamesystemLock {
@VisibleForTesting
static final String OP_NAME_OTHER = "OTHER";
- private static final String READ_LOCK_METRIC_PREFIX = "FSNReadLock";
- private static final String WRITE_LOCK_METRIC_PREFIX = "FSNWriteLock";
+ private final String readLockMetricPrefix;
+ private final String writeLockMetricPrefix;
private static final String LOCK_METRIC_SUFFIX = "Nanos";
private static final String OVERALL_METRIC_NAME = "Overall";
- public FSNamesystemLock(Configuration conf,
+ public FSNamesystemLock(Configuration conf, String lockName,
MutableRatesWithAggregation detailedHoldTimeMetrics) {
- this(conf, detailedHoldTimeMetrics, new Timer());
+ this(conf, lockName, detailedHoldTimeMetrics, new Timer());
}
@VisibleForTesting
- FSNamesystemLock(Configuration conf,
+ FSNamesystemLock(Configuration conf, String lockName,
MutableRatesWithAggregation detailedHoldTimeMetrics, Timer timer) {
+ this.lockName = lockName;
+ this.readLockMetricPrefix = this.lockName + "ReadLock";
+ this.writeLockMetricPrefix = this.lockName + "WriteLock";
boolean fair = conf.getBoolean(DFS_NAMENODE_FSLOCK_FAIR_KEY,
DFS_NAMENODE_FSLOCK_FAIR_DEFAULT);
- FSNamesystem.LOG.info("fsLock is fair: " + fair);
+ FSNamesystem.LOG.info("{}Lock is fair: {}.", this.lockName, fair);
this.coarseLock = new ReentrantReadWriteLock(fair);
this.timer = timer;
@@ -157,8 +161,8 @@ public class FSNamesystemLock {
this.metricsEnabled = conf.getBoolean(
DFS_NAMENODE_LOCK_DETAILED_METRICS_KEY,
DFS_NAMENODE_LOCK_DETAILED_METRICS_DEFAULT);
- FSNamesystem.LOG.info("Detailed lock hold time metrics enabled: " +
- this.metricsEnabled);
+ FSNamesystem.LOG.info("Detailed lock hold time metrics of {}Lock is {}.",
+ this.lockName, this.metricsEnabled ? "enabled" : "disabled");
this.detailedHoldTimeMetrics = detailedHoldTimeMetrics;
}
@@ -231,9 +235,9 @@ public class FSNamesystemLock {
LockHeldInfo lockHeldInfo =
longestReadLockHeldInfo.getAndSet(new LockHeldInfo());
FSNamesystem.LOG.info(
- "\tNumber of suppressed read-lock reports: {}"
+ "\tNumber of suppressed read-lock reports of {}Lock is {}"
+ "\n\tLongest read-lock held at {} for {}ms by {}{} via {}",
- numSuppressedWarnings, Time.formatTime(lockHeldInfo.getStartTimeMs()),
+ this.lockName, numSuppressedWarnings, Time.formatTime(lockHeldInfo.getStartTimeMs()),
lockHeldInfo.getIntervalMs(), lockHeldInfo.getOpName(),
lockHeldInfo.getLockReportInfo(), lockHeldInfo.getStackTrace());
}
@@ -337,10 +341,10 @@ public class FSNamesystemLock {
if (logAction.shouldLog()) {
FSNamesystem.LOG.info(
- "\tNumber of suppressed write-lock reports: {}"
+ "\tNumber of suppressed write-lock reports of {}Lock is {}"
+ "\n\tLongest write-lock held at {} for {}ms by {}{} via {}"
+ "\n\tTotal suppressed write-lock held time: {}",
- logAction.getCount() - 1,
+ this.lockName, logAction.getCount() - 1,
Time.formatTime(lockHeldInfo.getStartTimeMs()),
lockHeldInfo.getIntervalMs(), lockHeldInfo.getOpName(),
lockHeldInfo.getLockReportInfo(), lockHeldInfo.getStackTrace(),
@@ -456,8 +460,8 @@ public class FSNamesystemLock {
}
}
- private static String getMetricName(String operationName, boolean isWrite) {
- return (isWrite ? WRITE_LOCK_METRIC_PREFIX : READ_LOCK_METRIC_PREFIX) +
+ private String getMetricName(String operationName, boolean isWrite) {
+ return (isWrite ? this.writeLockMetricPrefix : this.readLockMetricPrefix) +
org.apache.commons.lang3.StringUtils.capitalize(operationName) +
LOCK_METRIC_SUFFIX;
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/FineGrainedFSNamesystemLock.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/FineGrainedFSNamesystemLock.java
index c2e3980476a9..2d67e68a2814 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/FineGrainedFSNamesystemLock.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/FineGrainedFSNamesystemLock.java
@@ -35,8 +35,8 @@ public class FineGrainedFSNamesystemLock implements FSNLockManager {
private final FSNamesystemLock bmLock;
public FineGrainedFSNamesystemLock(Configuration conf, MutableRatesWithAggregation aggregation) {
- this.fsLock = new FSNamesystemLock(conf, aggregation);
- this.bmLock = new FSNamesystemLock(conf, aggregation);
+ this.fsLock = new FSNamesystemLock(conf, "FS", aggregation);
+ this.bmLock = new FSNamesystemLock(conf, "BM", aggregation);
}
@Override
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/GlobalFSNamesystemLock.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/GlobalFSNamesystemLock.java
index c01529fac4c3..7c3a87d614e0 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/GlobalFSNamesystemLock.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/fgl/GlobalFSNamesystemLock.java
@@ -29,7 +29,7 @@ public class GlobalFSNamesystemLock implements FSNLockManager {
private final FSNamesystemLock lock;
public GlobalFSNamesystemLock(Configuration conf, MutableRatesWithAggregation aggregation) {
- this.lock = new FSNamesystemLock(conf, aggregation);
+ this.lock = new FSNamesystemLock(conf, "FSN", aggregation);
}
@Override
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
index f0ae18101670..512cd1531d6d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLock.java
@@ -57,17 +57,17 @@ public class TestFSNamesystemLock {
Configuration conf = new Configuration();
conf.setBoolean(DFS_NAMENODE_FSLOCK_FAIR_KEY, true);
- FSNamesystemLock fsnLock = new FSNamesystemLock(conf, null);
+ FSNamesystemLock fsnLock = new FSNamesystemLock(conf, "FSN", null);
assertTrue(fsnLock.coarseLock.isFair());
conf.setBoolean(DFS_NAMENODE_FSLOCK_FAIR_KEY, false);
- fsnLock = new FSNamesystemLock(conf, null);
+ fsnLock = new FSNamesystemLock(conf, "FSN", null);
assertFalse(fsnLock.coarseLock.isFair());
}
@Test
public void testFSNamesystemLockCompatibility() {
- FSNamesystemLock rwLock = new FSNamesystemLock(new Configuration(), null);
+ FSNamesystemLock rwLock = new FSNamesystemLock(new Configuration(), "FSN", null);
assertEquals(0, rwLock.getReadHoldCount());
rwLock.readLock();
@@ -107,7 +107,7 @@ public class TestFSNamesystemLock {
final CountDownLatch latch = new CountDownLatch(threadCount);
final Configuration conf = new Configuration();
conf.setBoolean(DFS_NAMENODE_FSLOCK_FAIR_KEY, true);
- final FSNamesystemLock rwLock = new FSNamesystemLock(conf, null);
+ final FSNamesystemLock rwLock = new FSNamesystemLock(conf, "FSN", null);
rwLock.writeLock();
ExecutorService helper = Executors.newFixedThreadPool(threadCount);
@@ -150,7 +150,7 @@ public class TestFSNamesystemLock {
writeLockSuppressWarningInterval, TimeUnit.MILLISECONDS);
final FakeTimer timer = new FakeTimer();
- final FSNamesystemLock fsnLock = new FSNamesystemLock(conf, null, timer);
+ final FSNamesystemLock fsnLock = new FSNamesystemLock(conf, "FSN", null, timer);
timer.advance(writeLockSuppressWarningInterval);
LogCapturer logs = LogCapturer.captureLogs(FSNamesystem.LOG);
@@ -213,7 +213,7 @@ public class TestFSNamesystemLock {
"held at " + Time.formatTime(timer.now()).substring(0, 10);
assertTrue(logs.getOutput().contains(startTimeStr));
assertTrue(logs.getOutput().contains(
- "Number of suppressed write-lock reports: 2"));
+ "Number of suppressed write-lock reports of FSNLock is 2"));
}
/**
@@ -233,7 +233,7 @@ public class TestFSNamesystemLock {
readLockSuppressWarningInterval, TimeUnit.MILLISECONDS);
final FakeTimer timer = new FakeTimer();
- final FSNamesystemLock fsnLock = new FSNamesystemLock(conf, null, timer);
+ final FSNamesystemLock fsnLock = new FSNamesystemLock(conf, "FSN", null, timer);
timer.advance(readLockSuppressWarningInterval);
LogCapturer logs = LogCapturer.captureLogs(FSNamesystem.LOG);
@@ -304,7 +304,7 @@ public class TestFSNamesystemLock {
"held at " + Time.formatTime(timer.now()).substring(0, 10);
assertTrue(logs.getOutput().contains(startTimeStr));
assertTrue(logs.getOutput().contains(
- "Number of suppressed read-lock reports: 3"));
+ "Number of suppressed read-lock reports of FSNLock is 3"));
// Report if it's held for a long time (and time since last report
// exceeds the suppress warning interval) while another thread also has the
@@ -366,7 +366,7 @@ public class TestFSNamesystemLock {
MetricsRegistry registry = new MetricsRegistry("Test");
MutableRatesWithAggregation rates =
registry.newRatesWithAggregation("Test");
- FSNamesystemLock fsLock = new FSNamesystemLock(conf, rates, timer);
+ FSNamesystemLock fsLock = new FSNamesystemLock(conf, "FSN", rates, timer);
fsLock.readLock();
timer.advanceNanos(1300000);
@@ -419,7 +419,7 @@ public class TestFSNamesystemLock {
writeLockSuppressWarningInterval, TimeUnit.MILLISECONDS);
final FakeTimer timer = new FakeTimer();
- final FSNamesystemLock fsnLock = new FSNamesystemLock(conf, null, timer);
+ final FSNamesystemLock fsnLock = new FSNamesystemLock(conf, "FSN", null, timer);
timer.advance(writeLockSuppressWarningInterval);
LogCapturer logs = LogCapturer.captureLogs(FSNamesystem.LOG);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org