Skip to content

Commit 0cd9ac3

Browse files
authored
fix: DH-21978: WorkerHeapSize column is Incorrect. (#7937)
This is the Core half of the fix, the performance queries are assuming the heap size we are analyzing is the same size as the current worker which is not a generally valid assumption. The Core+ half of the fix is to write the heap size down to permanent logs for later analysis.
1 parent 0902303 commit 0cd9ac3

5 files changed

Lines changed: 41 additions & 11 deletions

File tree

engine/table/src/main/java/io/deephaven/engine/table/impl/perf/UpdatePerformanceStreamPublisher.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.deephaven.engine.table.TableDefinition;
1010
import io.deephaven.engine.table.impl.perf.UpdatePerformanceTracker.IntervalLevelDetails;
1111
import io.deephaven.engine.table.impl.sources.ArrayBackedColumnSource;
12+
import io.deephaven.engine.table.impl.util.HeapSize;
1213
import io.deephaven.stream.StreamChunkUtils;
1314
import io.deephaven.stream.StreamConsumer;
1415
import io.deephaven.stream.StreamPublisher;
@@ -41,7 +42,8 @@ class UpdatePerformanceStreamPublisher implements StreamPublisher {
4142
ColumnDefinition.ofLong("AllocatedBytes"),
4243
ColumnDefinition.ofLong("PoolAllocatedBytes"),
4344
ColumnDefinition.ofString("AuthContext"),
44-
ColumnDefinition.ofString("UpdateGraph"));
45+
ColumnDefinition.ofString("UpdateGraph"),
46+
ColumnDefinition.ofLong("WorkerHeapSize"));
4547

4648
public static TableDefinition definition() {
4749
return DEFINITION;
@@ -51,9 +53,11 @@ public static TableDefinition definition() {
5153

5254
private WritableChunk<Values>[] chunks;
5355
private StreamConsumer consumer;
56+
private final long heapSize;
5457

5558
public UpdatePerformanceStreamPublisher() {
5659
chunks = StreamChunkUtils.makeChunksForDefinition(DEFINITION, CHUNK_SIZE);
60+
heapSize = HeapSize.getMaximumHeapSizeBytes();
5761
}
5862

5963
@Override
@@ -111,6 +115,8 @@ public synchronized void add(IntervalLevelDetails intervalLevelDetails, Performa
111115
chunks[21].<String>asWritableObjectChunk().add(Objects.toString(performanceEntry.getAuthContext()));
112116
// ColumnDefinition.ofString("UpdateGraph"));
113117
chunks[22].<String>asWritableObjectChunk().add(Objects.toString(performanceEntry.getUpdateGraphName()));
118+
// ColumnDefinition.ofLong("WorkerHeapSize")
119+
chunks[23].asWritableLongChunk().add(heapSize);
114120

115121
if (chunks[0].size() == CHUNK_SIZE) {
116122
flushInternal();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (c) 2016-2026 Deephaven Data Labs and Patent Pending
3+
//
4+
package io.deephaven.engine.table.impl.util;
5+
6+
import io.deephaven.util.QueryConstants;
7+
8+
/**
9+
* Get this process's maximum heap size for performance logs.
10+
*/
11+
public class HeapSize {
12+
/**
13+
* Get this process's maximum heap size in bytes, or {@link QueryConstants#NULL_LONG}.
14+
*
15+
* @return this processes maximum heap size in bytes, or {@link QueryConstants#NULL_LONG}.
16+
*/
17+
public static long getMaximumHeapSizeBytes() {
18+
return EngineMetrics.getProcessInfo().getMemoryInfo().heap().max().orElse(QueryConstants.NULL_LONG);
19+
}
20+
}

engine/table/src/main/java/io/deephaven/engine/table/impl/util/QueryOperationPerformanceStreamPublisher.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class QueryOperationPerformanceStreamPublisher implements StreamPublisher {
4444
ColumnDefinition.ofLong("PoolAllocatedBytes"),
4545
ColumnDefinition.ofLong("InputSizeLong"),
4646
ColumnDefinition.ofBoolean("WasInterrupted"),
47-
ColumnDefinition.ofString("AuthContext"));
47+
ColumnDefinition.ofString("AuthContext"),
48+
ColumnDefinition.ofLong("WorkerHeapSize"));
4849
private static final int CHUNK_SIZE = ArrayBackedColumnSource.BLOCK_SIZE;
4950

5051
public static TableDefinition definition() {
@@ -53,9 +54,11 @@ public static TableDefinition definition() {
5354

5455
private WritableChunk<Values>[] chunks;
5556
private StreamConsumer consumer;
57+
private final long heapSize;
5658

5759
QueryOperationPerformanceStreamPublisher() {
5860
chunks = StreamChunkUtils.makeChunksForDefinition(DEFINITION, CHUNK_SIZE);
61+
heapSize = HeapSize.getMaximumHeapSizeBytes();
5962
}
6063

6164
@Override
@@ -143,6 +146,9 @@ public synchronized void add(final QueryPerformanceNugget nugget) {
143146
// ColumnDefinition.ofString("AuthContext")
144147
chunks[24].<String>asWritableObjectChunk().add(Objects.toString(nugget.getAuthContext()));
145148

149+
// ColumnDefinition.ofLong("WorkerHeapSize")
150+
chunks[25].asWritableLongChunk().add(heapSize);
151+
146152
if (chunks[0].size() == CHUNK_SIZE) {
147153
flushInternal();
148154
}

engine/table/src/main/java/io/deephaven/engine/table/impl/util/QueryPerformanceStreamPublisher.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class QueryPerformanceStreamPublisher implements StreamPublisher {
4040
ColumnDefinition.ofLong("PoolAllocatedBytes"),
4141
ColumnDefinition.ofBoolean("WasInterrupted"),
4242
ColumnDefinition.ofString("Exception"),
43-
ColumnDefinition.ofString("AuthContext"));
43+
ColumnDefinition.ofString("AuthContext"),
44+
ColumnDefinition.ofLong("WorkerHeapSize"));
4445
private static final int CHUNK_SIZE = ArrayBackedColumnSource.BLOCK_SIZE;
4546

4647
public static TableDefinition definition() {
@@ -49,9 +50,11 @@ public static TableDefinition definition() {
4950

5051
private WritableChunk<Values>[] chunks;
5152
private StreamConsumer consumer;
53+
private final long heapSize;
5254

5355
QueryPerformanceStreamPublisher() {
5456
chunks = StreamChunkUtils.makeChunksForDefinition(DEFINITION, CHUNK_SIZE);
57+
heapSize = HeapSize.getMaximumHeapSizeBytes();
5558
}
5659

5760
@Override
@@ -126,6 +129,9 @@ public synchronized void add(
126129
// ColumnDefinition.ofString("AuthContext")
127130
chunks[19].<String>asWritableObjectChunk().add(Objects.toString(nugget.getAuthContext()));
128131

132+
// ColumnDefinition.ofLong("WorkerHeapSize")
133+
chunks[20].asWritableLongChunk().add(heapSize);
134+
129135
if (chunks[0].size() == CHUNK_SIZE) {
130136
flushInternal();
131137
}

extensions/performance/src/main/java/io/deephaven/engine/table/impl/util/PerformanceQueriesGeneral.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ public static Table queryPerformance(Table queryPerformanceLog, final long evalu
3939
queryPerformanceLog = queryPerformanceLog.where(whereConditionForEvaluationNumber(evaluationNumber));
4040
}
4141

42-
final long workerHeapSizeBytes = getWorkerHeapSizeBytes();
4342
queryPerformanceLog = queryPerformanceLog
4443
.updateView(
45-
"WorkerHeapSize = " + workerHeapSizeBytes + "L",
4644
// How long this query ran for, in nanoseconds
4745
"DurationNanos = EndTime - StartTime",
4846
// How long this query ran for, in seconds
@@ -106,11 +104,9 @@ public static Table queryUpdatePerformance(Table queryUpdatePerformance, final l
106104
queryUpdatePerformance = queryUpdatePerformance.where(whereConditionForEvaluationNumber(evaluationNumber));
107105
}
108106

109-
final long workerHeapSizeBytes = getWorkerHeapSizeBytes();
110107
queryUpdatePerformance = queryUpdatePerformance
111108
.updateView(
112109
"IntervalDurationNanos = IntervalEndTime - IntervalStartTime",
113-
"WorkerHeapSize = " + workerHeapSizeBytes + "L",
114110
// % of time during this interval that the operation was using CPU
115111
"Ratio = UsageNanos / IntervalDurationNanos",
116112
// Memory in use by the query. (Only includes active heap memory.)
@@ -370,10 +366,6 @@ private static Table formatColumnsAsPctUpdatePerformance(final Table updatePerfo
370366
return formatColumnsAsPct(updatePerformanceTable, "Ratio", "QueryMemUsedPct");
371367
}
372368

373-
private static long getWorkerHeapSizeBytes() {
374-
return EngineMetrics.getProcessInfo().getMemoryInfo().heap().max().orElse(0);
375-
}
376-
377369
private static String whereConditionForEvaluationNumber(final long evaluationNumber) {
378370
return "EvaluationNumber = " + evaluationNumber;
379371
}

0 commit comments

Comments
 (0)