Skip to content

Commit a9d9e34

Browse files
authored
feat: define BYTES_PER_KB constant for consistent byte-to-kilobyte conversions in metrics classes (#770)
1 parent 7cd1ff2 commit a9d9e34

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

geaflow/geaflow-common/src/main/java/org/apache/geaflow/common/metric/CycleMetrics.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
public class CycleMetrics implements Serializable {
2525

26+
private static final int BYTES_PER_KB = 1024;
27+
2628
private String name;
2729
private String pipelineName;
2830
private String opName;
@@ -172,9 +174,9 @@ public static CycleMetrics build(String metricName,
172174
cycleMetrics.setAvgGcTime(totalGcTime / taskNum);
173175
cycleMetrics.setSlowestTaskExecuteTime(slowestTaskExecuteTime);
174176
cycleMetrics.setInputRecords(totalInputRecords);
175-
cycleMetrics.setInputKb(totalInputBytes / 1024);
177+
cycleMetrics.setInputKb(totalInputBytes / BYTES_PER_KB);
176178
cycleMetrics.setOutputRecords(totalOutputRecords);
177-
cycleMetrics.setOutputKb(totalOutputBytes / 1024);
179+
cycleMetrics.setOutputKb(totalOutputBytes / BYTES_PER_KB);
178180
return cycleMetrics;
179181
}
180182

geaflow/geaflow-common/src/main/java/org/apache/geaflow/common/metric/ShuffleReadMetrics.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
public class ShuffleReadMetrics implements Serializable {
2525

26+
private static final int BYTES_PER_KB = 1024;
27+
2628
private int fetchSlices;
2729
/**
2830
* total records of fetch response.
@@ -123,7 +125,7 @@ public void incFetchWaitMs(long fetchWaitMs) {
123125

124126
@Override
125127
public String toString() {
126-
return "ReadMetrics{" + "fetchSlices=" + fetchSlices + ", fetchRecords=" + fetchRecords + ", decodeKB=" + decodeBytes / 1024 + ", fetchWaitMs=" + fetchWaitMs
128+
return "ReadMetrics{" + "fetchSlices=" + fetchSlices + ", fetchRecords=" + fetchRecords + ", decodeKB=" + decodeBytes / BYTES_PER_KB + ", fetchWaitMs=" + fetchWaitMs
127129
+ ", decodeMs=" + decodeMs + '}';
128130
}
129131
}

geaflow/geaflow-common/src/main/java/org/apache/geaflow/common/metric/ShuffleWriteMetrics.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
public class ShuffleWriteMetrics implements Serializable {
2525

26+
private static final int BYTES_PER_KB = 1024;
27+
2628
/**
2729
* total output channels.
2830
*/
@@ -216,7 +218,7 @@ public void updateMaxSpillKB(long spillKB) {
216218
@Override
217219
public String toString() {
218220
return "WriteMetrics{" + "outputRecords=" + writtenRecords + ", encodedKb="
219-
+ encodedSize / 1024 + ", encodeMs=" + encodeMs + ", spillNum=" + spillNum
221+
+ encodedSize / BYTES_PER_KB + ", encodeMs=" + encodeMs + ", spillNum=" + spillNum
220222
+ ", spillDisk=" + spillDisk + ", oomCnt=" + oomCount + ", spillMs=" + spillMs
221223
+ ", maxSpillKB=" + maxSpillKB + ", " + "maxSliceKB=" + maxSliceKB + ", channels="
222224
+ numChannels + ", writtenChannels=" + writtenChannels + '}';

0 commit comments

Comments
 (0)