Skip to content

Commit

Permalink
QueryPerformanceRecorder: Add TableService#Batch Support
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Nov 4, 2023
1 parent 77b25b0 commit f218401
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ private void completionRoutine(TableUpdate upstream, JobScheduler jobScheduler,
getUpdateGraph().addNotification(new TerminalNotification() {
@Override
public void run() {
synchronized (accumulated) {
final PerformanceEntry entry = getEntry();
if (entry != null) {
entry.accumulate(accumulated);
}
final PerformanceEntry entry = getEntry();
if (entry != null) {
entry.accumulate(accumulated);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* A smaller entry that simply records usage data, meant for aggregating into the larger entry.
*/
public class BasePerformanceEntry implements LogOutputAppendable {
private long intervalUsageNanos;
private long intervalTimeNanos;

private long intervalCpuNanos;
private long intervalUserCpuNanos;
Expand Down Expand Up @@ -46,7 +46,7 @@ public void onBaseEntryEnd() {
intervalCpuNanos =
plus(intervalCpuNanos, minus(ThreadProfiler.DEFAULT.getCurrentThreadCpuTime(), startCpuNanos));

intervalUsageNanos += System.nanoTime() - startTimeNanos;
intervalTimeNanos += System.nanoTime() - startTimeNanos;

intervalPoolAllocatedBytes = plus(intervalPoolAllocatedBytes,
minus(QueryPerformanceRecorder.getPoolAllocatedBytesForCurrentThread(), startPoolAllocatedBytes));
Expand All @@ -64,7 +64,7 @@ public void onBaseEntryEnd() {
void baseEntryReset() {
Assert.eqZero(startTimeNanos, "startTimeNanos");

intervalUsageNanos = 0;
intervalTimeNanos = 0;

intervalCpuNanos = 0;
intervalUserCpuNanos = 0;
Expand All @@ -73,8 +73,8 @@ void baseEntryReset() {
intervalPoolAllocatedBytes = 0;
}

public long getIntervalUsageNanos() {
return intervalUsageNanos;
public long getIntervalTimeNanos() {
return intervalTimeNanos;
}

public long getIntervalCpuNanos() {
Expand All @@ -96,7 +96,7 @@ public long getIntervalPoolAllocatedBytes() {
@Override
public LogOutput append(LogOutput logOutput) {
final LogOutput currentValues = logOutput.append("BasePerformanceEntry{")
.append(", intervalUsageNanos=").append(intervalUsageNanos)
.append(", intervalUsageNanos=").append(intervalTimeNanos)
.append(", intervalCpuNanos=").append(intervalCpuNanos)
.append(", intervalUserCpuNanos=").append(intervalUserCpuNanos)
.append(", intervalAllocatedBytes=").append(intervalAllocatedBytes)
Expand All @@ -114,8 +114,8 @@ LogOutput appendStart(LogOutput logOutput) {
.append(", startPoolAllocatedBytes=").append(startPoolAllocatedBytes);
}

public void accumulate(BasePerformanceEntry entry) {
this.intervalUsageNanos += entry.intervalUsageNanos;
public synchronized void accumulate(BasePerformanceEntry entry) {
this.intervalTimeNanos += entry.intervalTimeNanos;
this.intervalCpuNanos = plus(this.intervalCpuNanos, entry.intervalCpuNanos);
this.intervalUserCpuNanos = plus(this.intervalUserCpuNanos, entry.intervalUserCpuNanos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public LogOutput append(final LogOutput logOutput) {
.append(", description='").append(description).append('\'')
.append(", callerLine='").append(callerLine).append('\'')
.append(", authContext=").append(authContext)
.append(", intervalUsageNanos=").append(getIntervalUsageNanos())
.append(", intervalUsageNanos=").append(getIntervalTimeNanos())
.append(", intervalCpuNanos=").append(getIntervalCpuNanos())
.append(", intervalUserCpuNanos=").append(getIntervalUserCpuNanos())
.append(", intervalInvocationCount=").append(intervalInvocationCount)
Expand Down Expand Up @@ -217,7 +217,7 @@ public long getIntervalInvocationCount() {
*/
boolean shouldLogEntryInterval() {
return intervalInvocationCount > 0 &&
UpdatePerformanceTracker.LOG_THRESHOLD.shouldLog(getIntervalUsageNanos());
UpdatePerformanceTracker.LOG_THRESHOLD.shouldLog(getIntervalTimeNanos());
}

public void accumulate(PerformanceEntry entry) {
Expand Down
Loading

0 comments on commit f218401

Please sign in to comment.