advancedxy commented on code in PR #494:
URL: https://github.com/apache/incubator-uniffle/pull/494#discussion_r1080750076
##########
server/src/test/java/org/apache/uniffle/server/ShuffleTaskInfoTest.java:
##########
@@ -17,15 +17,47 @@
package org.apache.uniffle.server;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ShuffleTaskInfoTest {
+ @BeforeAll
+ public static void setup() {
+ ShuffleServerMetrics.register();
+ }
+
+ @AfterAll
+ public static void tearDown() {
+ ShuffleServerMetrics.clear();
+ }
+
+ @Test
+ public void hugePartitionTest() {
Review Comment:
If it's not too hard or too much effort, tests with concurrent write/update
are preferred.
##########
server/src/main/java/org/apache/uniffle/server/ShuffleTaskInfo.java:
##########
@@ -124,4 +136,32 @@ public long getPartitionDataSize(int shuffleId, int
partitionId) {
return size;
}
+ public boolean hasHugePartition() {
+ return existHugePartition;
+ }
+
+ public int getHugePartitionSize() {
+ return hugePartitionTags.values().stream().map(x -> x.size()).reduce((x,
y) -> x + y).orElse(0);
+ }
+
+ public void markHugePartition(int shuffleId, int partitionId) {
+ if (!existHugePartition) {
+ synchronized (this) {
+ if (!existHugePartition) {
+ ShuffleServerMetrics.gaugeAppWithHugePartitionNum.inc();
+ ShuffleServerMetrics.counterTotalAppWithHugePartitionNum.inc();
+ existHugePartition = true;
+ }
+ }
+ }
+
+ hugePartitionTags.computeIfAbsent(shuffleId, key ->
Maps.newConcurrentMap());
+
+ hugePartitionTags.get(shuffleId).computeIfAbsent(partitionId, key -> {
Review Comment:
I prefer a set here. Map<Integer, Boolean> has more memory overhead compared
to Set<Integer>
You can leverage set's ` boolean add(E e);` method's return boolean to
update metrics conditionally
##########
server/src/main/java/org/apache/uniffle/server/ShuffleTaskInfo.java:
##########
@@ -124,4 +136,32 @@ public long getPartitionDataSize(int shuffleId, int
partitionId) {
return size;
}
+ public boolean hasHugePartition() {
+ return !hugePartitionTags.isEmpty();
+ }
+
+ public int getHugePartitionSize() {
+ return hugePartitionTags.values().stream().map(x -> x.size()).reduce((x,
y) -> x + y).orElse(0);
+ }
+
+ public void markHugePartition(int shuffleId, int partitionId) {
+ if (!existHugePartition) {
Review Comment:
Could we use a `AtomicBoolean` and its `getAndSet` method to update app
count atomically?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]