Skip to content

Commit

Permalink
Use Long for EvaluationNumber in all Places
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Nov 4, 2023
1 parent f218401 commit 6b22969
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class PerformanceEntry extends BasePerformanceEntry implements TableListener.Entry {
private final int id;
private final int evaluationNumber;
private final long evaluationNumber;
private final int operationNumber;
private final String description;
private final String callerLine;
Expand All @@ -42,7 +42,7 @@ public class PerformanceEntry extends BasePerformanceEntry implements TableListe
private final RuntimeMemory.Sample startSample;
private final RuntimeMemory.Sample endSample;

PerformanceEntry(final int id, final int evaluationNumber, final int operationNumber,
PerformanceEntry(final int id, final long evaluationNumber, final int operationNumber,
final String description, final String callerLine, final String updateGraphName) {
this.id = id;
this.evaluationNumber = evaluationNumber;
Expand Down Expand Up @@ -144,7 +144,7 @@ public int getId() {
return id;
}

public int getEvaluationNumber() {
public long getEvaluationNumber() {
return evaluationNumber;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class QueryPerformanceNugget extends BasePerformanceEntry implements Seri
*/
static final QueryPerformanceNugget DUMMY_NUGGET = new QueryPerformanceNugget();

private final int evaluationNumber;
private final int parentEvaluationNumber;
private final long evaluationNumber;
private final long parentEvaluationNumber;
private final int operationNumber;
private final int parentOperationNumber;
private final int depth;
Expand Down Expand Up @@ -68,7 +68,7 @@ public class QueryPerformanceNugget extends BasePerformanceEntry implements Seri
* @param evaluationNumber A unique identifier for the query evaluation that triggered this nugget creation
* @param description The operation description
*/
QueryPerformanceNugget(final int evaluationNumber, final int parentEvaluationNumber, final String description) {
QueryPerformanceNugget(final long evaluationNumber, final long parentEvaluationNumber, final String description) {
this(evaluationNumber, parentEvaluationNumber, NULL_INT, NULL_INT, NULL_INT, description, false, true,
NULL_LONG);
}
Expand All @@ -88,8 +88,8 @@ public class QueryPerformanceNugget extends BasePerformanceEntry implements Seri
* @param inputSize The size of the input data
*/
QueryPerformanceNugget(
final int evaluationNumber,
final int parentEvaluationNumber,
final long evaluationNumber,
final long parentEvaluationNumber,
final int operationNumber,
final int parentOperationNumber,
final int depth,
Expand Down Expand Up @@ -133,8 +133,8 @@ public class QueryPerformanceNugget extends BasePerformanceEntry implements Seri
private QueryPerformanceNugget() {
startMemorySample = null;
endMemorySample = null;
evaluationNumber = NULL_INT;
parentEvaluationNumber = NULL_INT;
evaluationNumber = NULL_LONG;
parentEvaluationNumber = NULL_LONG;
operationNumber = NULL_INT;
parentOperationNumber = NULL_INT;
depth = 0;
Expand Down Expand Up @@ -225,11 +225,11 @@ public String toString() {
+ ":" + callerLine;
}

public int getEvaluationNumber() {
public long getEvaluationNumber() {
return evaluationNumber;
}

public int getParentEvaluationNumber() {
public long getParentEvaluationNumber() {
return parentEvaluationNumber;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class QueryPerformanceRecorder implements Serializable {
private static final long serialVersionUID = 2L;
private static final String[] packageFilters;

private volatile boolean hasSubQuery;
private volatile boolean mustLogForHierarchicalConsistency;
private QueryPerformanceNugget queryNugget;
private final ArrayList<QueryPerformanceNugget> operationNuggets = new ArrayList<>();

Expand Down Expand Up @@ -102,7 +102,7 @@ private QueryPerformanceRecorder() {
* @param description A description for the query.
*/
public void startQuery(final String description) {
startQuery(description, QueryConstants.NULL_INT);
startQuery(description, QueryConstants.NULL_LONG);
}

/**
Expand All @@ -111,7 +111,7 @@ public void startQuery(final String description) {
* @param description A description for the query.
* @param parentEvaluationNumber The evaluation number of the parent query.
*/
public synchronized void startQuery(final String description, final int parentEvaluationNumber) {
public synchronized void startQuery(final String description, final long parentEvaluationNumber) {
clear();
final int evaluationNumber = queriesProcessed.getAndIncrement();
queryNugget = new QueryPerformanceNugget(evaluationNumber, parentEvaluationNumber, description);
Expand Down Expand Up @@ -291,7 +291,7 @@ synchronized boolean releaseNugget(QueryPerformanceNugget nugget) {
}

public interface EntrySetter {
void set(int evaluationNumber, int operationNumber, boolean uninstrumented);
void set(long evaluationNumber, int operationNumber, boolean uninstrumented);
}

public synchronized QueryPerformanceNugget getOuterNugget() {
Expand All @@ -300,7 +300,7 @@ public synchronized QueryPerformanceNugget getOuterNugget() {

// returns true if uninstrumented code data was captured.
public void setQueryData(final EntrySetter setter) {
final int evaluationNumber;
final long evaluationNumber;
final int operationNumber;
boolean uninstrumented = false;
synchronized (this) {
Expand All @@ -326,7 +326,9 @@ public void setQueryData(final EntrySetter setter) {
}

public void accumulate(@NotNull final QueryPerformanceRecorder subQuery) {
hasSubQuery = true;
if (subQuery.mustLogForHierarchicalConsistency()) {
mustLogForHierarchicalConsistency = true;
}
queryNugget.addBaseEntry(subQuery.queryNugget);
}

Expand All @@ -337,12 +339,12 @@ private void clear() {
userNuggetStack.clear();
}

public int getEvaluationNumber() {
public long getEvaluationNumber() {
return queryNugget.getEvaluationNumber();
}

public boolean hasSubQuery() {
return hasSubQuery;
public boolean mustLogForHierarchicalConsistency() {
return mustLogForHierarchicalConsistency || !operationNuggets.isEmpty();
}

public synchronized QueryPerformanceNugget getQueryLevelPerformanceData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class UpdatePerformanceStreamPublisher implements StreamPublisher {
private static final TableDefinition DEFINITION = TableDefinition.of(
ColumnDefinition.ofString("ProcessUniqueId"),
ColumnDefinition.ofInt("EntryId"),
ColumnDefinition.ofInt("EvaluationNumber"),
ColumnDefinition.ofLong("EvaluationNumber"),
ColumnDefinition.ofInt("OperationNumber"),
ColumnDefinition.ofString("EntryDescription"),
ColumnDefinition.ofString("EntryCallerLine"),
Expand Down Expand Up @@ -70,7 +70,7 @@ public void register(@NotNull StreamConsumer consumer) {
public synchronized void add(IntervalLevelDetails intervalLevelDetails, PerformanceEntry performanceEntry) {
chunks[0].<String>asWritableObjectChunk().add(EngineMetrics.getProcessInfo().getId().value());
chunks[1].asWritableIntChunk().add(performanceEntry.getId());
chunks[2].asWritableIntChunk().add(performanceEntry.getEvaluationNumber());
chunks[2].asWritableLongChunk().add(performanceEntry.getEvaluationNumber());
chunks[3].asWritableIntChunk().add(performanceEntry.getOperationNumber());
chunks[4].<String>asWritableObjectChunk().add(performanceEntry.getDescription());
chunks[5].<String>asWritableObjectChunk().add(performanceEntry.getCallerLine());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void add(
@Nullable TableListener.Entry entry,
@Nullable TableListener.Entry sourceEntry,
Throwable originalException) {
final int evaluationNumber;
final long evaluationNumber;
final int operationNumber;
final String description;
if (entry instanceof PerformanceEntry) {
Expand All @@ -52,7 +52,7 @@ public void add(
operationNumber = QueryConstants.NULL_INT;
description = null;
}
final int sourceEvaluationNumber;
final long sourceEvaluationNumber;
final int sourceOperationNumber;
final String sourceDescription;
if (sourceEntry instanceof PerformanceEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class AsyncErrorStreamPublisher implements StreamPublisher {

private static final TableDefinition DEFINITION = TableDefinition.of(
ColumnDefinition.ofTime("Time"),
ColumnDefinition.ofInt("EvaluationNumber"),
ColumnDefinition.ofLong("EvaluationNumber"),
ColumnDefinition.ofInt("OperationNumber"),
ColumnDefinition.ofString("Description"),
ColumnDefinition.ofInt("SourceQueryEvaluationNumber"),
ColumnDefinition.ofLong("SourceQueryEvaluationNumber"),
ColumnDefinition.ofInt("SourceQueryOperationNumber"),
ColumnDefinition.ofString("SourceQueryDescription"),
ColumnDefinition.of("Cause", Type.ofCustom(Throwable.class)));
Expand Down Expand Up @@ -51,18 +51,18 @@ public void register(@NotNull StreamConsumer consumer) {

public synchronized void add(
long timeNanos,
int evaluationNumber,
long evaluationNumber,
int operationNumber,
String description,
int sourceQueryEvaluationNumber,
long sourceQueryEvaluationNumber,
int sourceQueryOperationNumber,
String sourceQueryDescription,
Throwable cause) {
chunks[0].asWritableLongChunk().add(timeNanos);
chunks[1].asWritableIntChunk().add(evaluationNumber);
chunks[1].asWritableLongChunk().add(evaluationNumber);
chunks[2].asWritableIntChunk().add(operationNumber);
chunks[3].<String>asWritableObjectChunk().add(description);
chunks[4].asWritableIntChunk().add(sourceQueryEvaluationNumber);
chunks[4].asWritableLongChunk().add(sourceQueryEvaluationNumber);
chunks[5].asWritableIntChunk().add(sourceQueryOperationNumber);
chunks[6].<String>asWritableObjectChunk().add(sourceQueryDescription);
chunks[7].<Throwable>asWritableObjectChunk().add(cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.deephaven.process.ProcessInfoConfig;
import io.deephaven.stats.Driver;
import io.deephaven.stats.StatsIntradayLogger;
import io.deephaven.util.QueryConstants;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand Down Expand Up @@ -122,17 +121,17 @@ public void logQueryProcessingResults(@NotNull final QueryProcessingResults resu
"queryProcessingResults.getRecorder().getQueryLevelPerformanceData()");

synchronized (qplLogger) {
qplLogger.log(results.getRecorder().getEvaluationNumber(), results, queryNugget);
qplLogger.log(results, queryNugget);
}
final List<QueryPerformanceNugget> nuggets =
results.getRecorder().getOperationLevelPerformanceData();
synchronized (qoplLogger) {
if (results.getRecorder().hasSubQuery() || !nuggets.isEmpty()) {
if (results.getRecorder().mustLogForHierarchicalConsistency()) {
// if this query has sub queries or op nuggets add log an entry to enable hierarchical consistency
qoplLogger.log(queryNugget.getOperationNumber(), queryNugget);
qoplLogger.log(queryNugget);
}
for (QueryPerformanceNugget n : nuggets) {
qoplLogger.log(n.getOperationNumber(), n);
for (QueryPerformanceNugget nugget : nuggets) {
qoplLogger.log(nugget);
}
}
} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public Table blinkTable() {
}

@Override
public void log(Flags flags, int operationNumber, QueryPerformanceNugget nugget) throws IOException {
public void log(Flags flags, QueryPerformanceNugget nugget) throws IOException {
publisher.add(id.value(), nugget);
qoplLogger.log(flags, operationNumber, nugget);
qoplLogger.log(flags, nugget);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import io.deephaven.stream.StreamChunkUtils;
import io.deephaven.stream.StreamConsumer;
import io.deephaven.stream.StreamPublisher;
import io.deephaven.time.DateTimeUtils;
import io.deephaven.util.BooleanUtils;
import io.deephaven.util.QueryConstants;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;
Expand All @@ -23,8 +21,8 @@ class QueryOperationPerformanceStreamPublisher implements StreamPublisher {

private static final TableDefinition DEFINITION = TableDefinition.of(
ColumnDefinition.ofString("ProcessUniqueId"),
ColumnDefinition.ofInt("EvaluationNumber"),
ColumnDefinition.ofInt("ParentEvaluationNumber"),
ColumnDefinition.ofLong("EvaluationNumber"),
ColumnDefinition.ofLong("ParentEvaluationNumber"),
ColumnDefinition.ofInt("OperationNumber"),
ColumnDefinition.ofInt("ParentOperationNumber"),
ColumnDefinition.ofInt("Depth"),
Expand Down Expand Up @@ -73,8 +71,8 @@ public synchronized void add(
final QueryPerformanceNugget nugget) {

chunks[0].<String>asWritableObjectChunk().add(id);
chunks[1].asWritableIntChunk().add(nugget.getEvaluationNumber());
chunks[2].asWritableIntChunk().add(nugget.getParentEvaluationNumber());
chunks[1].asWritableLongChunk().add(nugget.getEvaluationNumber());
chunks[2].asWritableLongChunk().add(nugget.getParentEvaluationNumber());
chunks[3].asWritableIntChunk().add(nugget.getOperationNumber());
chunks[4].asWritableIntChunk().add(nugget.getParentOperationNumber());
chunks[5].asWritableIntChunk().add(nugget.getDepth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public Table blinkTable() {
}

@Override
public void log(Flags flags, long evaluationNumber, QueryProcessingResults queryProcessingResults,
public void log(Flags flags, QueryProcessingResults queryProcessingResults,
QueryPerformanceNugget nugget) throws IOException {
publisher.add(id.value(), queryProcessingResults, nugget);
qplLogger.log(flags, evaluationNumber, queryProcessingResults, nugget);
qplLogger.log(flags, queryProcessingResults, nugget);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.deephaven.stream.StreamConsumer;
import io.deephaven.stream.StreamPublisher;
import io.deephaven.util.BooleanUtils;
import io.deephaven.util.QueryConstants;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;
Expand Down Expand Up @@ -71,12 +70,10 @@ public synchronized void add(
chunks[0].<String>asWritableObjectChunk().add(id);

// ColumnDefinition.ofLong("EvaluationNumber")
final int en = nugget.getEvaluationNumber();
chunks[1].asWritableLongChunk().add(en == QueryConstants.NULL_INT ? QueryConstants.NULL_LONG : en);
chunks[1].asWritableLongChunk().add(nugget.getEvaluationNumber());

// ColumnDefinition.ofLong("ParentEvaluationNumber")
final int pen = nugget.getParentEvaluationNumber();
chunks[2].asWritableLongChunk().add(pen == QueryConstants.NULL_INT ? QueryConstants.NULL_LONG : pen);
chunks[2].asWritableLongChunk().add(nugget.getParentEvaluationNumber());

// ColumnDefinition.ofTime("StartTime");
chunks[3].asWritableLongChunk().add(nugget.getStartClockTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
* queries.
*/
public interface QueryOperationPerformanceLogLogger {
default void log(final int operationNumber, final QueryPerformanceNugget nugget) throws IOException {
log(DEFAULT_INTRADAY_LOGGER_FLAGS, operationNumber, nugget);
default void log(final QueryPerformanceNugget nugget) throws IOException {
log(DEFAULT_INTRADAY_LOGGER_FLAGS, nugget);
}

void log(final Row.Flags flags, final int operationNumber, final QueryPerformanceNugget nugget) throws IOException;
void log(Row.Flags flags, QueryPerformanceNugget nugget) throws IOException;

enum Noop implements QueryOperationPerformanceLogLogger {
INSTANCE;

@Override
public void log(Flags flags, int operationNumber, QueryPerformanceNugget nugget) throws IOException {
public void log(Flags flags, QueryPerformanceNugget nugget) throws IOException {

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
* each will have its own set of query performance log entries.
*/
public interface QueryPerformanceLogLogger {
default void log(final long evaluationNumber, final QueryProcessingResults queryProcessingResults,
default void log(
final QueryProcessingResults queryProcessingResults,
final QueryPerformanceNugget nugget) throws IOException {
log(DEFAULT_INTRADAY_LOGGER_FLAGS, evaluationNumber, queryProcessingResults, nugget);
log(DEFAULT_INTRADAY_LOGGER_FLAGS, queryProcessingResults, nugget);
}

void log(final Row.Flags flags, final long evaluationNumber, final QueryProcessingResults queryProcessingResults,
final QueryPerformanceNugget nugget) throws IOException;
void log(Row.Flags flags, QueryProcessingResults queryProcessingResults, QueryPerformanceNugget nugget)
throws IOException;

enum Noop implements QueryPerformanceLogLogger {
INSTANCE;

@Override
public void log(Flags flags, long evaluationNumber, QueryProcessingResults queryProcessingResults,
QueryPerformanceNugget nugget) throws IOException {
public void log(Flags flags, QueryProcessingResults queryProcessingResults, QueryPerformanceNugget nugget)
throws IOException {

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,9 @@ private void doExport() {
try (final SafeCloseable ignored1 = session.executionContext.open()) {
try (final SafeCloseable ignored2 = LivenessScopeStack.open()) {
queryProcessingResults = new QueryProcessingResults(QueryPerformanceRecorder.getInstance());
final int parentEvaluationNumber = queryPerformanceRecorder != null
final long parentEvaluationNumber = queryPerformanceRecorder != null
? queryPerformanceRecorder.getEvaluationNumber()
: QueryConstants.NULL_INT;
: QueryConstants.NULL_LONG;
QueryPerformanceRecorder.getInstance().startQuery(
"ExportObject#doWork(session=" + session.sessionId + ",exportId=" + logIdentity + ")",
parentEvaluationNumber);
Expand Down

0 comments on commit 6b22969

Please sign in to comment.