Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Nov 21, 2023
1 parent b732db3 commit 870f277
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ default QueryPerformanceNugget getNugget(@NotNull String name) {
* {@link QueryPerformanceNugget#DUMMY_NUGGET} if no recorder is installed.
*
* @param name the nugget name
* @return A new QueryPerformanceNugget to encapsulate the compilation. {@link QueryPerformanceNugget#close()}
* must be called on the nugget.
* @return A new QueryPerformanceNugget to encapsulate the compilation. {@link QueryPerformanceNugget#close()} must
* be called on the nugget.
*/
QueryPerformanceNugget getCompilationNugget(@NotNull String name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public synchronized QueryPerformanceNugget getNugget(@NotNull final String name,
@Override
public QueryPerformanceNugget getCompilationNugget(@NotNull final String name) {
return getNuggetInternal(parent -> nuggetFactory.createForCompilation(
parent, operationNuggets.size(), "Compile: " + name, this::releaseNugget));
parent, operationNuggets.size(), name, this::releaseNugget));
}

private QueryPerformanceNugget getNuggetInternal(
Expand Down Expand Up @@ -309,22 +309,18 @@ public synchronized QueryPerformanceNugget getEnclosingNugget() {
public void supplyQueryData(final @NotNull QueryDataConsumer consumer) {
final long evaluationNumber;
final int operationNumber;
boolean uninstrumented = false;
final boolean uninstrumented;
synchronized (this) {
// we should never be called if we're not running
Assert.eq(state, "state", QueryState.RUNNING, "QueryState.RUNNING");
evaluationNumber = queryNugget.getEvaluationNumber();
operationNumber = operationNuggets.size();
if (operationNumber > 0) {
// ensure UPL and QOPL are consistent/joinable.
if (!userNuggetStack.isEmpty()) {
userNuggetStack.getLast().setShouldLog();
} else {
uninstrumented = true;
Assert.neqNull(catchAllNugget, "catchAllNugget");
catchAllNugget.setShouldLog();
}
}

final QueryPerformanceNugget nugget = getEnclosingNugget();
evaluationNumber = nugget.getEvaluationNumber();
operationNumber = nugget.getOperationNumber();
uninstrumented = nugget == catchAllNugget;

// ensure UPL and QOPL are consistent/joinable.
nugget.setShouldLog();
}
consumer.accept(evaluationNumber, operationNumber, uninstrumented);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class QueryPerformanceStreamPublisher implements StreamPublisher {
private static final TableDefinition DEFINITION = TableDefinition.of(
ColumnDefinition.ofLong("EvaluationNumber"),
ColumnDefinition.ofLong("ParentEvaluationNumber"),
ColumnDefinition.ofString("Description"),
ColumnDefinition.ofString("SessionId"),
ColumnDefinition.ofString("Description"),
ColumnDefinition.ofTime("StartTime"),
ColumnDefinition.ofTime("EndTime"),
ColumnDefinition.ofLong("UsageNanos"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static Map<String, Table> queryUpdatePerformanceMap(final Table queryUpda
"EntryDescription",
"IntervalDurationNanos",
"Ratio",
"Usage",
"UsageNanos",
"RowsAdded",
"RowsRemoved",
"RowsModified",
Expand All @@ -172,12 +172,19 @@ public static Map<String, Table> queryUpdatePerformanceMap(final Table queryUpda
// interval, operations are still sorted with the greatest Ratio at the top.)
Table updateMostRecent = updateWorst.sortDescending("IntervalEndTime").moveColumnsUp("IntervalEndTime");

final String[] groupByColumns;
if (qup.hasColumns("ProcessUniqueId")) {
groupByColumns = new String[] {"IntervalStartTime", "IntervalEndTime", "ProcessUniqueId"};
} else {
groupByColumns = new String[] {"IntervalStartTime", "IntervalEndTime"};
}

// Create a table that summarizes the update performance data within each interval
Table updateAggregate = qup.aggBy(
Arrays.asList(
AggSum("NRows", "UsageNanos"),
AggFirst("QueryMemUsed", "WorkerHeapSize", "QueryMemUsedPct", "IntervalDurationNanos")),
"IntervalStartTime", "IntervalEndTime", "ProcessUniqueId")
groupByColumns)
.updateView("Ratio = UsageNanos / IntervalDurationNanos")
.moveColumnsUp("IntervalStartTime", "IntervalEndTime", "Ratio");

Expand Down

0 comments on commit 870f277

Please sign in to comment.