[improvement](profile) do not remove value 0 counter (#24487)

do not remove value 0 counter
This commit is contained in:
Mryange
2023-09-18 15:31:19 +08:00
committed by GitHub
parent 1d1eeaec4a
commit b9f1ac153a
2 changed files with 13 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import org.apache.doris.thrift.TUnit;
public class Counter {
private volatile long value;
private volatile int type;
private volatile boolean remove = false;
public long getValue() {
return value;
@ -68,4 +69,12 @@ public class Counter {
TUnit ttype = TUnit.findByValue(type);
return ttype == TUnit.TIME_MS || ttype == TUnit.TIME_NS || ttype == TUnit.TIME_S;
}
public void setCanRemove() {
this.remove = true;
}
public boolean isRemove() {
return this.remove;
}
}

View File

@ -399,7 +399,7 @@ public class RuntimeProfile {
mergeProfileCounter(src, childCounterName, rhs);
mergeCounter(src, childCounterName, counter, rhsCounter);
removeZeroeCounter(childCounterSet, childCounterName, counter);
removeCounter(childCounterSet, childCounterName, counter);
}
}
@ -423,8 +423,8 @@ public class RuntimeProfile {
}
}
private static void removeZeroeCounter(Set<String> childCounterSet, String childCounterName, Counter counter) {
if (counter.getValue() == 0) {
private static void removeCounter(Set<String> childCounterSet, String childCounterName, Counter counter) {
if (counter.isRemove()) {
childCounterSet.remove(childCounterName);
}
}
@ -476,7 +476,7 @@ public class RuntimeProfile {
+ MIN_TIME_PRE + printCounter(minCounter.getValue(), minCounter.getType()) + " ]";
src.infoStrings.put(counterName, infoString);
}
counter.setValue(0); // value 0 will remove in removeZeroeCounter
counter.setCanRemove(); // value will remove in removeCounter
} else {
if (rhsCounter.size() == 0) {
return;