Skip to content
Open
Changes from all commits
Commits
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
14 changes: 10 additions & 4 deletions src/java/org/apache/cassandra/db/ReadExecutionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ReadExecutionController implements AutoCloseable
private final RepairedDataInfo repairedDataInfo;
private long oldestUnrepairedTombstone = Long.MAX_VALUE;

public final Histogram sstablesScannedPerRowRead;
private final Histogram sstablesScannedPerRowRead;

ReadExecutionController(ReadCommand command,
OpOrder.Group baseOp,
Expand All @@ -75,7 +75,10 @@ public class ReadExecutionController implements AutoCloseable
this.command = command;
this.createdAtNanos = createdAtNanos;

this.sstablesScannedPerRowRead = new Histogram(new DecayingEstimatedHistogramReservoir(true));
// This is expensive to create, and since this is on the query hot path, we must only make it when we need it.
this.sstablesScannedPerRowRead = Tracing.isTracing()
? new Histogram(new DecayingEstimatedHistogramReservoir(true))
: null;

if (trackRepairedStatus)
{
Expand Down Expand Up @@ -228,7 +231,7 @@ public void close()
if (createdAtNanos != NO_SAMPLING)
addSample();

if (Tracing.traceSinglePartitions())
if (sstablesScannedPerRowRead != null)
{
Snapshot sstablesHistogram = sstablesScannedPerRowRead.getSnapshot();
Tracing.trace("Scanned {} rows; average {} sstables scanned per row with stdev {} and max {}",
Expand Down Expand Up @@ -272,6 +275,9 @@ private void addSample()

public void updateSstablesIteratedPerRow(int mergedSSTablesIterated)
{
sstablesScannedPerRowRead.update(mergedSSTablesIterated);
if (sstablesScannedPerRowRead != null)
{
sstablesScannedPerRowRead.update(mergedSSTablesIterated);
}
}
}