Skip to content

[SPARK-21052][SQL][Follow-up] Add hash map metrics to join #18480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,10 @@ public final class BytesToBytesMap extends MemoryConsumer {

private final boolean enablePerfMetrics;

private long timeSpentResizingNs = 0;

private long numProbes = 0;

private long numKeyLookups = 0;

private long numHashCollisions = 0;

private long peakMemoryUsedBytes = 0L;

private final int initialCapacity;
Expand Down Expand Up @@ -489,10 +485,6 @@ public void safeLookup(Object keyBase, long keyOffset, int keyLength, Location l
);
if (areEqual) {
return;
} else {
if (enablePerfMetrics) {
numHashCollisions++;
}
}
}
}
Expand Down Expand Up @@ -859,16 +851,6 @@ public long getPeakMemoryUsedBytes() {
return peakMemoryUsedBytes;
}

/**
* Returns the total amount of time spent resizing this map (in nanoseconds).
*/
public long getTimeSpentResizingNs() {
if (!enablePerfMetrics) {
throw new IllegalStateException();
}
return timeSpentResizingNs;
}

/**
* Returns the average number of probes per key lookup.
*/
Expand All @@ -879,13 +861,6 @@ public double getAverageProbesPerLookup() {
return (1.0 * numProbes) / numKeyLookups;
}

public long getNumHashCollisions() {
if (!enablePerfMetrics) {
throw new IllegalStateException();
}
return numHashCollisions;
}

@VisibleForTesting
public int getNumDataPages() {
return dataPages.size();
Expand Down Expand Up @@ -923,10 +898,6 @@ public void reset() {
void growAndRehash() {
assert(longArray != null);

long resizeStartTime = -1;
if (enablePerfMetrics) {
resizeStartTime = System.nanoTime();
}
// Store references to the old data structures to be used when we re-hash
final LongArray oldLongArray = longArray;
final int oldCapacity = (int) oldLongArray.size() / 2;
Expand All @@ -951,9 +922,5 @@ void growAndRehash() {
longArray.set(newPos * 2 + 1, hashcode);
}
freeArray(oldLongArray);

if (enablePerfMetrics) {
timeSpentResizingNs += System.nanoTime() - resizeStartTime;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ trait HashJoin {

// At the end of the task, we update the avg hash probe.
TaskContext.get().addTaskCompletionListener(_ =>
avgHashProbe.set(hashed.getAverageProbesPerLookup()))
avgHashProbe.set(hashed.getAverageProbesPerLookup))

val resultProj = createResultProjection
joinedIter.map { r =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private[execution] sealed trait HashedRelation extends KnownSizeEstimation {
/**
* Returns the average number of probes per key lookup.
*/
def getAverageProbesPerLookup(): Double
def getAverageProbesPerLookup: Double
}

private[execution] object HashedRelation {
Expand Down Expand Up @@ -280,7 +280,7 @@ private[joins] class UnsafeHashedRelation(
read(in.readInt, in.readLong, in.readBytes)
}

override def getAverageProbesPerLookup(): Double = binaryMap.getAverageProbesPerLookup()
override def getAverageProbesPerLookup: Double = binaryMap.getAverageProbesPerLookup
}

private[joins] object UnsafeHashedRelation {
Expand Down Expand Up @@ -776,7 +776,7 @@ private[execution] final class LongToUnsafeRowMap(val mm: TaskMemoryManager, cap
/**
* Returns the average number of probes per key lookup.
*/
def getAverageProbesPerLookup(): Double = numProbes.toDouble / numKeyLookups
def getAverageProbesPerLookup: Double = numProbes.toDouble / numKeyLookups
}

private[joins] class LongHashedRelation(
Expand Down Expand Up @@ -829,7 +829,7 @@ private[joins] class LongHashedRelation(
map = in.readObject().asInstanceOf[LongToUnsafeRowMap]
}

override def getAverageProbesPerLookup(): Double = map.getAverageProbesPerLookup()
override def getAverageProbesPerLookup: Double = map.getAverageProbesPerLookup
}

/**
Expand Down