Skip to content
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

QueryPerformanceRecorder: Group Batched Operations as a Single Query #4760

Merged
merged 31 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2450cba
QueryPerformanceRecorder: Add TableService#Batch Support
nbauernfeind Nov 4, 2023
5bc13da
Use Long for EvaluationNumber in all Places
nbauernfeind Nov 4, 2023
c5cf808
Fix QOPL Column Mismatches
nbauernfeind Nov 4, 2023
95eae63
unused imports
nbauernfeind Nov 4, 2023
dfa80de
Performance Tracking for One-Shot Ticket Resolution
nbauernfeind Nov 4, 2023
d4c8e2a
Majority of Rnd2 Feedback
nbauernfeind Nov 8, 2023
81dd004
Split QueryPerformanceRecorder in Two
nbauernfeind Nov 8, 2023
02d4838
PerformanceQueries Changes
nbauernfeind Nov 9, 2023
5b9fdc0
Personal Review
nbauernfeind Nov 9, 2023
567dc98
Bug Fix for CI
nbauernfeind Nov 9, 2023
2695c07
revert cpp-test host change
nbauernfeind Nov 9, 2023
be34bb2
bugfix SessionState where resetInstance occurs
nbauernfeind Nov 9, 2023
4563ed9
Fix suspend query ordering in SessionState for one shot
nbauernfeind Nov 9, 2023
9d00dd2
Bug Fixes + Inline Review Changes
nbauernfeind Nov 9, 2023
2ddb440
Non-invasive Rnd3 Feedback
nbauernfeind Nov 13, 2023
8d30cc6
The invasive changes of rnd3 feedback
nbauernfeind Nov 13, 2023
e337210
The Fixes
nbauernfeind Nov 14, 2023
78b6b44
Personal Review
nbauernfeind Nov 14, 2023
e5fdfc2
Chip's Suggestions from CR
nbauernfeind Nov 14, 2023
10e455f
Add python tests for the new QPL QOPL tree table methods
nbauernfeind Nov 14, 2023
42e04f2
Audited ExportObject Creation
nbauernfeind Nov 15, 2023
6851328
Publishing State Change Bug ??
nbauernfeind Nov 15, 2023
947f854
ExportObject Builder API - Explicit Methods for Sub-Query vs Resume
nbauernfeind Nov 15, 2023
771ec36
put nugget inside of resolve call.. (duh)
nbauernfeind Nov 15, 2023
58d366a
Make non-export descriptions clearer
nbauernfeind Nov 15, 2023
fc006e7
rm unused import
nbauernfeind Nov 15, 2023
9460a59
Synchronous Review Changes 11/16
nbauernfeind Nov 17, 2023
6f742b6
Add SessionId to QPL and QOPL
nbauernfeind Nov 17, 2023
e08a97b
Create QPR Sub-Query During Batch Delegation
nbauernfeind Nov 17, 2023
6bf84eb
almost final round?
nbauernfeind Nov 17, 2023
962f55c
most recent review comments
nbauernfeind Nov 18, 2023
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 @@ -1269,7 +1269,7 @@ void handleUncaughtException(Exception throwable) {
initialFilterExecution.getBasePerformanceEntry();
if (basePerformanceEntry != null) {
final QueryPerformanceNugget outerNugget =
QueryPerformanceRecorder.getInstance().getOuterNugget();
QueryPerformanceRecorder.getInstance().getEnclosingNugget();
if (outerNugget != null) {
outerNugget.accumulate(basePerformanceEntry);
}
Expand Down Expand Up @@ -1517,7 +1517,7 @@ this, mode, columns, rowSet, getModifiedColumnSetForUpdates(), publishTheseSourc
final BasePerformanceEntry baseEntry = jobScheduler.getAccumulatedPerformance();
if (baseEntry != null) {
final QueryPerformanceNugget outerNugget =
QueryPerformanceRecorder.getInstance().getOuterNugget();
QueryPerformanceRecorder.getInstance().getEnclosingNugget();
if (outerNugget != null) {
outerNugget.accumulate(baseEntry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ synchronized void baseEntryReset() {
}

/**
* Get the aggregate usage in nanoseconds. Invoking this getter is valid iff the entry will no longer be mutated.
* Get the aggregate usage in nanoseconds. This getter should be called by exclusive owners of the entry, and never
* concurrently with mutators.
*
* @return total wall clock time in nanos
*/
Expand All @@ -84,7 +85,8 @@ public long getUsageNanos() {
}

/**
* Get the aggregate cpu time in nanoseconds. Invoking this getter is valid iff the entry will no longer be mutated.
* Get the aggregate cpu time in nanoseconds. This getter should be called by exclusive owners of the entry, and
* never concurrently with mutators.
*
* @return total cpu time in nanos
*/
Expand All @@ -93,8 +95,8 @@ public long getCpuNanos() {
}

/**
* Get the aggregate cpu user time in nanoseconds. Invoking this getter is valid iff the entry will no longer be
* mutated.
* Get the aggregate cpu user time in nanoseconds. This getter should be called by exclusive owners of the entry,
* and never concurrently with mutators.
*
* @return total cpu user time in nanos
*/
Expand All @@ -103,8 +105,8 @@ public long getUserCpuNanos() {
}

/**
* Get the aggregate allocated memory in bytes. Invoking this getter is valid iff the entry will no longer be
* mutated.
* Get the aggregate allocated memory in bytes. This getter should be called by exclusive owners of the entry, and
* never concurrently with mutators.
*
* @return The bytes of allocated memory attributed to the instrumented operation.
*/
Expand All @@ -113,8 +115,8 @@ public long getAllocatedBytes() {
}

/**
* Get allocated pooled/reusable memory attributed to the instrumented operation in bytes. Invoking this getter is
* valid iff the entry will no longer be mutated.
* Get allocated pooled/reusable memory attributed to the instrumented operation in bytes. This getter should be
* called by exclusive owners of the entry, and never concurrently with mutators.
*
* @return total pool allocated memory in bytes
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public class QueryPerformanceNugget extends BasePerformanceEntry implements Safe
public void accumulate(@NotNull BasePerformanceEntry entry) {
// non-synchronized no-op override
}

@Override
public boolean shouldLogThisAndStackParents() {
return false;
}

@Override
boolean shouldLogNugget(boolean isUninstrumented) {
return false;
}
nbauernfeind marked this conversation as resolved.
Show resolved Hide resolved
};

public interface Factory {
Expand Down Expand Up @@ -322,15 +332,16 @@ public boolean isUser() {
return isUser;
}

public boolean isBatchLevel() {
return isQueryLevel() && parentEvaluationNumber == NULL_LONG;
}

public boolean isQueryLevel() {
return operationNumber == NULL_INT;
}

public boolean isTopLevel() {
public boolean isTopLevelQuery() {
return isQueryLevel() && parentEvaluationNumber == NULL_LONG;
}

public boolean isTopLevelOperation() {
// note that query level nuggets have depth == NULL_INT
return depth == 0;
}

Expand Down Expand Up @@ -416,15 +427,15 @@ public boolean wasInterrupted() {
/**
* Ensure this nugget gets logged, alongside its stack of nesting operations.
*/
public void setShouldLogThisAndStackParents() {
void setShouldLogThisAndStackParents() {
shouldLogThisAndStackParents = true;
}

/**
* @return true if this nugget triggers the logging of itself and every other nugget in its stack of nesting
* operations.
*/
public boolean shouldLogThisAndStackParents() {
boolean shouldLogThisAndStackParents() {
return shouldLogThisAndStackParents;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,32 @@ public static void resetInstance() {
}

/**
* Create a nugget at the top of the user stack. May return a {@link QueryPerformanceNugget#DUMMY_NUGGET} if no
* recorder is installed.
*
* @param name the nugget name
* @return A new QueryPerformanceNugget to encapsulate user query operations. done() must be called on the nugget.
* @return A new QueryPerformanceNugget to encapsulate user query operations. {@link QueryPerformanceNugget#done()}
* or {@link QueryPerformanceNugget#close()} must be called on the nugget.
*/
public abstract QueryPerformanceNugget getNugget(@NotNull String name);

/**
* Create a nugget at the top of the user stack. May return a {@link QueryPerformanceNugget#DUMMY_NUGGET} if no
* recorder is installed.
*
* @param name the nugget name
* @param inputSize the nugget's input size
* @return A new QueryPerformanceNugget to encapsulate user query operations. done() must be called on the nugget.
* @return A new QueryPerformanceNugget to encapsulate user query operations. {@link QueryPerformanceNugget#done()}
* or {@link QueryPerformanceNugget#close()} must be called on the nugget.
*/
public abstract QueryPerformanceNugget getNugget(@NotNull String name, long inputSize);

/**
* @return The nugget currently in effect or else a dummy nugget if no nugget is in effect.
* This is the nugget enclosing the current operation. It may belong to the dummy recorder, or a real one.
*
* @return Either a "catch-all" nugget, or the top of the user nugget stack.
*/
public abstract QueryPerformanceNugget getOuterNugget();
public abstract QueryPerformanceNugget getEnclosingNugget();

/**
* <b>Note:</b> Do not call this directly - it's for nugget use only. Call {@link QueryPerformanceNugget#done()} or
Expand Down Expand Up @@ -462,7 +472,7 @@ public QueryPerformanceNugget getNugget(@NotNull final String name, long inputSi
}

@Override
public QueryPerformanceNugget getOuterNugget() {
public QueryPerformanceNugget getEnclosingNugget() {
return QueryPerformanceNugget.DUMMY_NUGGET;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ synchronized boolean releaseNugget(@NotNull final QueryPerformanceNugget nugget)
}

@Override
public synchronized QueryPerformanceNugget getOuterNugget() {
public synchronized QueryPerformanceNugget getEnclosingNugget() {
nbauernfeind marked this conversation as resolved.
Show resolved Hide resolved
return userNuggetStack.peekLast();
}

Expand Down Expand Up @@ -321,7 +321,7 @@ public synchronized Table getTimingResultsAsTable() {
timeNanos[i] = operationNuggets.get(i).getUsageNanos();
names[i] = operationNuggets.get(i).getName();
callerLine[i] = operationNuggets.get(i).getCallerLine();
isTopLevel[i] = operationNuggets.get(i).isTopLevel();
isTopLevel[i] = operationNuggets.get(i).isTopLevelOperation();
isCompileTime[i] = operationNuggets.get(i).getName().startsWith("Compile:");
}
return TableTools.newTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
*/
package io.deephaven.engine.table.impl.perf;

import java.io.Serializable;

public class QueryProcessingResults implements Serializable {

private static final long serialVersionUID = 2L;
public class QueryProcessingResults {

private final QueryPerformanceRecorder recorder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ private void cleanUpAndNotify(final Runnable onCleanupComplete) {
final BasePerformanceEntry accumulated = jobScheduler.getAccumulatedPerformance();
if (accumulated != null) {
if (initialStep) {
final QueryPerformanceNugget outerNugget = QueryPerformanceRecorder.getInstance().getOuterNugget();
final QueryPerformanceNugget outerNugget =
nbauernfeind marked this conversation as resolved.
Show resolved Hide resolved
QueryPerformanceRecorder.getInstance().getEnclosingNugget();
if (outerNugget != null) {
outerNugget.accumulate(accumulated);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,9 @@ public void batch(
} else {
safelyComplete(responseObserver);
}
queryPerformanceRecorder.endQuery();
EngineMetrics.getInstance().logQueryProcessingResults(results);
if (queryPerformanceRecorder.endQuery()) {
EngineMetrics.getInstance().logQueryProcessingResults(results);
nbauernfeind marked this conversation as resolved.
Show resolved Hide resolved
}
} finally {
QueryPerformanceRecorder.resetInstance();
}
Expand Down