Skip to content

Commit 529e571

Browse files
committed
Measure timeSpentResizing in nanoseconds instead of milliseconds.
1 parent 3ca84b2 commit 529e571

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeFixedWidthAggregationMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public void printPerfMetrics() {
248248
}
249249
System.out.println("Average probes per lookup: " + map.getAverageProbesPerLookup());
250250
System.out.println("Number of hash collisions: " + map.getNumHashCollisions());
251-
System.out.println("Time spent resizing (ms): " + map.getTimeSpentResizingMs());
251+
System.out.println("Time spent resizing (ns): " + map.getTimeSpentResizingNs());
252252
System.out.println("Total memory consumption (bytes): " + map.getTotalMemoryConsumption());
253253
}
254254

unsafe/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public final class BytesToBytesMap {
124124

125125
private final boolean enablePerfMetrics;
126126

127-
private long timeSpentResizingMs = 0;
127+
private long timeSpentResizingNs = 0;
128128

129129
private long numProbes = 0;
130130

@@ -470,13 +470,13 @@ public long getTotalMemoryConsumption() {
470470
}
471471

472472
/**
473-
* Returns the total amount of time spent resizing this map (in milliseconds).
473+
* Returns the total amount of time spent resizing this map (in nanoseconds).
474474
*/
475-
public long getTimeSpentResizingMs() {
475+
public long getTimeSpentResizingNs() {
476476
if (!enablePerfMetrics) {
477477
throw new IllegalStateException();
478478
}
479-
return timeSpentResizingMs;
479+
return timeSpentResizingNs;
480480
}
481481

482482

@@ -503,7 +503,7 @@ public long getNumHashCollisions() {
503503
private void growAndRehash() {
504504
long resizeStartTime = -1;
505505
if (enablePerfMetrics) {
506-
resizeStartTime = System.currentTimeMillis();
506+
resizeStartTime = System.nanoTime();
507507
}
508508
// Store references to the old data structures to be used when we re-hash
509509
final LongArray oldLongArray = longArray;
@@ -540,7 +540,7 @@ private void growAndRehash() {
540540
memoryManager.allocator.free(oldLongArray.memoryBlock());
541541
memoryManager.allocator.free(oldBitSet.memoryBlock());
542542
if (enablePerfMetrics) {
543-
timeSpentResizingMs += System.currentTimeMillis() - resizeStartTime;
543+
timeSpentResizingNs += System.nanoTime() - resizeStartTime;
544544
}
545545
}
546546

0 commit comments

Comments
 (0)