Skip to content

Commit

Permalink
Change from dataSize to long to avoid unnecessary creation
Browse files Browse the repository at this point in the history
  • Loading branch information
shangm2 committed Feb 19, 2025
1 parent 9c4b683 commit 4495d51
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@

import com.facebook.presto.operator.BlockedReason;
import com.google.common.collect.ImmutableSet;
import io.airlift.units.DataSize;
import io.airlift.units.Duration;

import java.util.HashSet;
import java.util.OptionalDouble;
import java.util.Set;

import static io.airlift.units.DataSize.Unit.BYTE;
import static io.airlift.units.DataSize.succinctBytes;
import static com.google.common.base.Preconditions.checkArgument;
import static io.airlift.units.Duration.succinctDuration;
import static java.lang.Math.min;
import static java.util.Objects.requireNonNull;
Expand All @@ -39,21 +37,21 @@ public class BasicStageExecutionStats
0,
0,

new DataSize(0, BYTE),
0L,
0,

0.0,
0.0,
new DataSize(0, BYTE),
new DataSize(0, BYTE),
0L,
0L,

new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),

false,
ImmutableSet.of(),

new DataSize(0, BYTE),
0L,

OptionalDouble.empty());

Expand All @@ -62,17 +60,17 @@ public class BasicStageExecutionStats
private final int queuedDrivers;
private final int runningDrivers;
private final int completedDrivers;
private final DataSize rawInputDataSize;
private final long rawInputDataSizeInBytes;
private final long rawInputPositions;
private final double cumulativeUserMemory;
private final double cumulativeTotalMemory;
private final DataSize userMemoryReservation;
private final DataSize totalMemoryReservation;
private final long userMemoryReservationInBytes;
private final long totalMemoryReservationInBytes;
private final Duration totalCpuTime;
private final Duration totalScheduledTime;
private final boolean fullyBlocked;
private final Set<BlockedReason> blockedReasons;
private final DataSize totalAllocation;
private final long totalAllocationInBytes;
private final OptionalDouble progressPercentage;

public BasicStageExecutionStats(
Expand All @@ -83,21 +81,21 @@ public BasicStageExecutionStats(
int runningDrivers,
int completedDrivers,

DataSize rawInputDataSize,
long rawInputDataSizeInBytes,
long rawInputPositions,

double cumulativeUserMemory,
double cumulativeTotalMemory,
DataSize userMemoryReservation,
DataSize totalMemoryReservation,
long userMemoryReservationInBytes,
long totalMemoryReservationInBytes,

Duration totalCpuTime,
Duration totalScheduledTime,

boolean fullyBlocked,
Set<BlockedReason> blockedReasons,

DataSize totalAllocation,
long totalAllocationInBytes,

OptionalDouble progressPercentage)
{
Expand All @@ -106,17 +104,21 @@ public BasicStageExecutionStats(
this.queuedDrivers = queuedDrivers;
this.runningDrivers = runningDrivers;
this.completedDrivers = completedDrivers;
this.rawInputDataSize = requireNonNull(rawInputDataSize, "rawInputDataSize is null");
checkArgument(rawInputDataSizeInBytes >= 0, "rawInputDataSizeInBytes is negative");
this.rawInputDataSizeInBytes = rawInputDataSizeInBytes;
this.rawInputPositions = rawInputPositions;
this.cumulativeUserMemory = cumulativeUserMemory;
this.cumulativeTotalMemory = cumulativeTotalMemory;
this.userMemoryReservation = requireNonNull(userMemoryReservation, "userMemoryReservation is null");
this.totalMemoryReservation = requireNonNull(totalMemoryReservation, "totalMemoryReservation is null");
checkArgument(userMemoryReservationInBytes >= 0, "userMemoryReservationInBytes is negative");
this.userMemoryReservationInBytes = userMemoryReservationInBytes;
checkArgument(totalMemoryReservationInBytes >= 0, "totalMemoryReservationInBytes is negative");
this.totalMemoryReservationInBytes = totalMemoryReservationInBytes;
this.totalCpuTime = requireNonNull(totalCpuTime, "totalCpuTime is null");
this.totalScheduledTime = requireNonNull(totalScheduledTime, "totalScheduledTime is null");
this.fullyBlocked = fullyBlocked;
this.blockedReasons = ImmutableSet.copyOf(requireNonNull(blockedReasons, "blockedReasons is null"));
this.totalAllocation = requireNonNull(totalAllocation, "totalAllocation is null");
checkArgument(totalAllocationInBytes >= 0, "totalAllocationInBytes is negative");
this.totalAllocationInBytes = totalAllocationInBytes;
this.progressPercentage = requireNonNull(progressPercentage, "progressPercentage is null");
}

Expand Down Expand Up @@ -145,9 +147,9 @@ public int getCompletedDrivers()
return completedDrivers;
}

public DataSize getRawInputDataSize()
public long getRawInputDataSizeInBytes()
{
return rawInputDataSize;
return rawInputDataSizeInBytes;
}

public long getRawInputPositions()
Expand All @@ -165,14 +167,14 @@ public double getCumulativeTotalMemory()
return cumulativeTotalMemory;
}

public DataSize getUserMemoryReservation()
public long getUserMemoryReservationInBytes()
{
return userMemoryReservation;
return userMemoryReservationInBytes;
}

public DataSize getTotalMemoryReservation()
public long getTotalMemoryReservationInBytes()
{
return totalMemoryReservation;
return totalMemoryReservationInBytes;
}

public Duration getTotalCpuTime()
Expand All @@ -195,9 +197,9 @@ public Set<BlockedReason> getBlockedReasons()
return blockedReasons;
}

public DataSize getTotalAllocation()
public long getTotalAllocationInBytes()
{
return totalAllocation;
return totalAllocationInBytes;
}

public OptionalDouble getProgressPercentage()
Expand Down Expand Up @@ -238,8 +240,8 @@ public static BasicStageExecutionStats aggregateBasicStageStats(Iterable<BasicSt

cumulativeUserMemory += stageStats.getCumulativeUserMemory();
cumulativeTotalMemory += stageStats.getCumulativeTotalMemory();
userMemoryReservation += stageStats.getUserMemoryReservation().toBytes();
totalMemoryReservation += stageStats.getTotalMemoryReservation().toBytes();
userMemoryReservation += stageStats.getUserMemoryReservationInBytes();
totalMemoryReservation += stageStats.getTotalMemoryReservationInBytes();

totalScheduledTimeMillis += stageStats.getTotalScheduledTime().roundTo(MILLISECONDS);
totalCpuTime += stageStats.getTotalCpuTime().roundTo(MILLISECONDS);
Expand All @@ -249,9 +251,9 @@ public static BasicStageExecutionStats aggregateBasicStageStats(Iterable<BasicSt
fullyBlocked &= stageStats.isFullyBlocked();
blockedReasons.addAll(stageStats.getBlockedReasons());

totalAllocation += stageStats.getTotalAllocation().toBytes();
totalAllocation += stageStats.getTotalAllocationInBytes();

rawInputDataSize += stageStats.getRawInputDataSize().toBytes();
rawInputDataSize += stageStats.getRawInputDataSizeInBytes();
rawInputPositions += stageStats.getRawInputPositions();
}

Expand All @@ -268,21 +270,21 @@ public static BasicStageExecutionStats aggregateBasicStageStats(Iterable<BasicSt
runningDrivers,
completedDrivers,

succinctBytes(rawInputDataSize),
rawInputDataSize,
rawInputPositions,

cumulativeUserMemory,
cumulativeTotalMemory,
succinctBytes(userMemoryReservation),
succinctBytes(totalMemoryReservation),
userMemoryReservation,
totalMemoryReservation,

succinctDuration(totalCpuTime, MILLISECONDS),
succinctDuration(totalScheduledTimeMillis, MILLISECONDS),

fullyBlocked,
blockedReasons,

succinctBytes(totalAllocation),
totalAllocation,

progressPercentage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,13 @@ public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageExecutionStats> rootS
stageStats.getRunningDrivers(),
stageStats.getCompletedDrivers(),

stageStats.getRawInputDataSize(),
succinctBytes(stageStats.getRawInputDataSizeInBytes()),
stageStats.getRawInputPositions(),

stageStats.getCumulativeUserMemory(),
stageStats.getCumulativeTotalMemory(),
stageStats.getUserMemoryReservation(),
stageStats.getTotalMemoryReservation(),
succinctBytes(stageStats.getUserMemoryReservationInBytes()),
succinctBytes(stageStats.getTotalMemoryReservationInBytes()),
succinctBytes(getPeakUserMemoryInBytes()),
succinctBytes(getPeakTotalMemoryInBytes()),
succinctBytes(getPeakTaskTotalMemory()),
Expand All @@ -406,7 +406,7 @@ public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageExecutionStats> rootS
stageStats.isFullyBlocked(),
stageStats.getBlockedReasons(),

stageStats.getTotalAllocation(),
succinctBytes(stageStats.getTotalAllocationInBytes()),

stageStats.getProgressPercentage());

Expand Down
Loading

0 comments on commit 4495d51

Please sign in to comment.