This is an automated email from the ASF dual-hosted git repository.
zhouky pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new 320714bf2 [CELEBORN-1089] Seperate overHighWatermark check to a
dedicated thread
320714bf2 is described below
commit 320714bf24c16031f127350602cdbac656ab07f4
Author: onebox-li <[email protected]>
AuthorDate: Wed Nov 1 09:51:24 2023 +0800
[CELEBORN-1089] Seperate overHighWatermark check to a dedicated thread
### What changes were proposed in this pull request?
Seperate `overHighWatermark` check to a dedicated thread, let this value
can shared better and lighten `CongestionController#isUserCongested` logic.
### Why are the changes needed?
Ditto.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Manual test and UT.
Closes #2041 from onebox-li/congest-check.
Authored-by: onebox-li <[email protected]>
Signed-off-by: zky.zhoukeyong <[email protected]>
---
.../org/apache/celeborn/common/CelebornConf.scala | 10 ++++
docs/configuration/worker.md | 1 +
.../congestcontrol/CongestionController.java | 58 +++++++++++++---------
.../celeborn/service/deploy/worker/Worker.scala | 4 +-
.../congestcontrol/TestCongestionController.java | 9 +++-
5 files changed, 57 insertions(+), 25 deletions(-)
diff --git
a/common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala
b/common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala
index 306e8f29e..3c717fa5a 100644
--- a/common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala
+++ b/common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala
@@ -1014,6 +1014,7 @@ class CelebornConf(loadDefaults: Boolean) extends
Cloneable with Logging with Se
get(WORKER_CONGESTION_CONTROL_HIGH_WATERMARK)
def workerCongestionControlUserInactiveIntervalMs: Long =
get(WORKER_CONGESTION_CONTROL_USER_INACTIVE_INTERVAL)
+ def workerCongestionControlCheckIntervalMs: Long =
get(WORKER_CONGESTION_CONTROL_CHECK_INTERVAL)
// //////////////////////////////////////////////////////
// Columnar Shuffle //
@@ -2633,6 +2634,15 @@ object CelebornConf extends Logging {
.timeConf(TimeUnit.MILLISECONDS)
.createWithDefaultString("10min")
+ val WORKER_CONGESTION_CONTROL_CHECK_INTERVAL: ConfigEntry[Long] =
+ buildConf("celeborn.worker.congestionControl.check.interval")
+ .categories("worker")
+ .doc(
+ s"Interval of worker checks congestion if
${WORKER_CONGESTION_CONTROL_ENABLED.key} is true.")
+ .version("0.3.2")
+ .timeConf(TimeUnit.MILLISECONDS)
+ .createWithDefaultString("10ms")
+
val WORKER_DECOMMISSION_CHECK_INTERVAL: ConfigEntry[Long] =
buildConf("celeborn.worker.decommission.checkInterval")
.categories("worker")
diff --git a/docs/configuration/worker.md b/docs/configuration/worker.md
index 62c6e5a15..8154101b0 100644
--- a/docs/configuration/worker.md
+++ b/docs/configuration/worker.md
@@ -29,6 +29,7 @@ license: |
| celeborn.worker.closeIdleConnections | false | Whether worker will close
idle connections. | 0.2.0 |
| celeborn.worker.commitFiles.threads | 32 | Thread number of worker to commit
shuffle data files asynchronously. It's recommended to set at least `128` when
`HDFS` is enabled in `celeborn.storage.activeTypes`. | 0.3.0 |
| celeborn.worker.commitFiles.timeout | 120s | Timeout for a Celeborn worker
to commit files of a shuffle. It's recommended to set at least `240s` when
`HDFS` is enabled in `celeborn.storage.activeTypes`. | 0.3.0 |
+| celeborn.worker.congestionControl.check.interval | 10ms | Interval of worker
checks congestion if celeborn.worker.congestionControl.enabled is true. | 0.3.2
|
| celeborn.worker.congestionControl.enabled | false | Whether to enable
congestion control or not. | 0.3.0 |
| celeborn.worker.congestionControl.high.watermark | <undefined> | If
the total bytes in disk buffer exceeds this configure, will start to
congestusers whose produce rate is higher than the potential average consume
rate. The congestion will stop if the produce rate is lower or equal to the
average consume rate, or the total pending bytes lower than
celeborn.worker.congestionControl.low.watermark | 0.3.0 |
| celeborn.worker.congestionControl.low.watermark | <undefined> | Will
stop congest users if the total pending bytes of disk buffer is lower than this
configuration | 0.3.0 |
diff --git
a/worker/src/main/java/org/apache/celeborn/service/deploy/worker/congestcontrol/CongestionController.java
b/worker/src/main/java/org/apache/celeborn/service/deploy/worker/congestcontrol/CongestionController.java
index 6b6ecbb3c..662d1fe30 100644
---
a/worker/src/main/java/org/apache/celeborn/service/deploy/worker/congestcontrol/CongestionController.java
+++
b/worker/src/main/java/org/apache/celeborn/service/deploy/worker/congestcontrol/CongestionController.java
@@ -52,12 +52,15 @@ public class CongestionController {
private final ScheduledExecutorService removeUserExecutorService;
+ private final ScheduledExecutorService checkService;
+
protected CongestionController(
WorkerSource workerSource,
int sampleTimeWindowSeconds,
long highWatermark,
long lowWatermark,
- long userInactiveTimeMills) {
+ long userInactiveTimeMills,
+ long checkIntervalTimeMills) {
assert (highWatermark > lowWatermark);
this.workerSource = workerSource;
@@ -74,6 +77,11 @@ public class CongestionController {
this.removeUserExecutorService.scheduleWithFixedDelay(
this::removeInactiveUsers, 0, userInactiveTimeMills,
TimeUnit.MILLISECONDS);
+ this.checkService =
ThreadUtils.newDaemonSingleThreadScheduledExecutor("congestion-checker");
+
+ this.checkService.scheduleWithFixedDelay(
+ this::checkCongestion, 0, checkIntervalTimeMills,
TimeUnit.MILLISECONDS);
+
this.workerSource.addGauge(
WorkerSource.POTENTIAL_CONSUME_SPEED(),
this::getPotentialConsumeSpeed);
@@ -86,14 +94,16 @@ public class CongestionController {
int sampleTimeWindowSeconds,
long highWatermark,
long lowWatermark,
- long userInactiveTimeMills) {
+ long userInactiveTimeMills,
+ long checkIntervalTimeMills) {
_INSTANCE =
new CongestionController(
workSource,
sampleTimeWindowSeconds,
highWatermark,
lowWatermark,
- userInactiveTimeMills);
+ userInactiveTimeMills,
+ checkIntervalTimeMills);
return _INSTANCE;
}
@@ -137,26 +147,7 @@ public class CongestionController {
if (userBufferStatuses.size() == 0) {
return false;
}
-
- long pendingConsumed = getTotalPendingBytes();
- if (pendingConsumed > highWatermark &&
overHighWatermark.compareAndSet(false, true)) {
- logger.info(
- "Pending consume bytes: {} higher than high watermark, need to
congest it",
- pendingConsumed);
- }
-
if (overHighWatermark.get()) {
- trimMemoryUsage();
- pendingConsumed = getTotalPendingBytes();
-
- if (pendingConsumed < lowWatermark &&
overHighWatermark.compareAndSet(true, false)) {
- logger.info("Lower than low watermark, exit congestion control");
- }
-
- if (!overHighWatermark.get()) {
- return false;
- }
-
// If the user produce speed is higher that the avg consume speed, will
congest it
long userProduceSpeed =
getUserProduceSpeed(userBufferStatuses.get(userIdentifier));
long avgConsumeSpeed = getPotentialConsumeSpeed();
@@ -245,12 +236,33 @@ public class CongestionController {
}
}
} catch (Exception e) {
- logger.error("Error occurs when removing inactive users, ", e);
+ logger.error("Error occurs when removing inactive users", e);
+ }
+ }
+
+ protected void checkCongestion() {
+ try {
+ long pendingConsume = getTotalPendingBytes();
+ if (pendingConsume < lowWatermark) {
+ if (overHighWatermark.compareAndSet(true, false)) {
+ logger.info("Pending consume is lower than low watermark, exit
congestion control");
+ }
+ return;
+ } else if (pendingConsume > highWatermark &&
overHighWatermark.compareAndSet(false, true)) {
+ logger.info("Pending consume is higher than high watermark, need
congestion control");
+ }
+ if (overHighWatermark.get()) {
+ trimMemoryUsage();
+ }
+ } catch (Exception e) {
+ logger.error("Congestion check error", e);
}
}
public void close() {
+ logger.info("Closing {}", this.getClass().getSimpleName());
this.removeUserExecutorService.shutdownNow();
+ this.checkService.shutdownNow();
this.userBufferStatuses.clear();
this.consumedBufferStatusHub.clear();
}
diff --git
a/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
b/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
index f95808437..6c0f981ce 100644
---
a/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
+++
b/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
@@ -128,7 +128,8 @@ private[celeborn] class Worker(
conf.workerCongestionControlSampleTimeWindowSeconds.toInt,
conf.workerCongestionControlHighWatermark.get,
conf.workerCongestionControlLowWatermark.get,
- conf.workerCongestionControlUserInactiveIntervalMs)
+ conf.workerCongestionControlUserInactiveIntervalMs,
+ conf.workerCongestionControlCheckIntervalMs)
}
var controller = new Controller(rpcEnv, conf, metricsSystem, workerSource)
@@ -454,6 +455,7 @@ private[celeborn] class Worker(
partitionsSorter.close(exitKind)
storageManager.close(exitKind)
memoryManager.close()
+ Option(CongestionController.instance()).foreach(_.close())
masterClient.close()
replicateServer.shutdown(exitKind)
diff --git
a/worker/src/test/java/org/apache/celeborn/service/deploy/worker/congestcontrol/TestCongestionController.java
b/worker/src/test/java/org/apache/celeborn/service/deploy/worker/congestcontrol/TestCongestionController.java
index f9d564079..b8fb5cadc 100644
---
a/worker/src/test/java/org/apache/celeborn/service/deploy/worker/congestcontrol/TestCongestionController.java
+++
b/worker/src/test/java/org/apache/celeborn/service/deploy/worker/congestcontrol/TestCongestionController.java
@@ -37,12 +37,14 @@ public class TestCongestionController {
private long pendingBytes = 0L;
private final long userInactiveTimeMills = 2000L;
+ private final long checkIntervalTimeMills = Integer.MAX_VALUE;
@Before
public void initialize() {
// Make sampleTimeWindow a bit larger in case the tests run time exceed
this window.
controller =
- new CongestionController(source, 10, 1000, 500, userInactiveTimeMills)
{
+ new CongestionController(
+ source, 10, 1000, 500, userInactiveTimeMills,
checkIntervalTimeMills) {
@Override
public long getTotalPendingBytes() {
return pendingBytes;
@@ -69,10 +71,12 @@ public class TestCongestionController {
controller.produceBytes(userIdentifier, 1001);
pendingBytes = 1001;
+ controller.checkCongestion();
Assert.assertTrue(controller.isUserCongested(userIdentifier));
controller.consumeBytes(1001);
pendingBytes = 0;
+ controller.checkCongestion();
Assert.assertFalse(controller.isUserCongested(userIdentifier));
}
@@ -91,6 +95,7 @@ public class TestCongestionController {
controller.produceBytes(user2, 201);
controller.consumeBytes(500);
pendingBytes = 1001;
+ controller.checkCongestion();
Assert.assertTrue(controller.isUserCongested(user1));
Assert.assertFalse(controller.isUserCongested(user2));
@@ -99,11 +104,13 @@ public class TestCongestionController {
controller.produceBytes(user2, 800);
controller.consumeBytes(500);
pendingBytes = 1600;
+ controller.checkCongestion();
Assert.assertTrue(controller.isUserCongested(user1));
Assert.assertTrue(controller.isUserCongested(user2));
// If pending bytes lower than the low watermark, should don't congest all
users.
pendingBytes = 0;
+ controller.checkCongestion();
Assert.assertFalse(controller.isUserCongested(user1));
Assert.assertFalse(controller.isUserCongested(user2));
}