Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class StreamStatisticNames {
public static final String STREAM_READ_ABORTED = "stream_aborted";

/**
* Bytes read from an input stream in read() calls.
* Bytes read from an input stream in read()/readVectored() calls.
* Does not include bytes read and then discarded in seek/close etc.
* These are the bytes returned to the caller.
* Value: {@value}.
Expand Down Expand Up @@ -110,6 +110,34 @@ public final class StreamStatisticNames {
public static final String STREAM_READ_OPERATIONS =
"stream_read_operations";

/**
* Count of readVectored() operations in an input stream.
* Value: {@value}.
*/
public static final String STREAM_READ_VECTORED_OPERATIONS =
"stream_read_vectored_operations";

/**
* Count of bytes discarded during readVectored() operation
* in an input stream.
* Value: {@value}.
*/
public static final String STREAM_READ_VECTORED_READ_BYTES_DISCARDED =
"stream_read_vectored_read_bytes_discarded";

/**
* Count of incoming file ranges during readVectored() operation.
* Value: {@value}
*/
public static final String STREAM_READ_VECTORED_INCOMING_RANGES =
"stream_read_vectored_incoming_ranges";
/**
* Count of combined file ranges during readVectored() operation.
* Value: {@value}
*/
public static final String STREAM_READ_VECTORED_COMBINED_RANGES =
"stream_read_vectored_combined_ranges";

/**
* Count of incomplete read() operations in an input stream,
* that is, when the bytes returned were less than that requested.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public IntFunction<ByteBuffer> getAllocate() {
return allocate;
}

public WeakReferencedElasticByteBufferPool getPool() {
return pool;
}

@Override
public void setup() throws Exception {
super.setup();
Expand Down Expand Up @@ -382,6 +386,13 @@ protected List<FileRange> getSampleOverlappingRanges() {
return fileRanges;
}

protected List<FileRange> getConsecutiveRanges() {
List<FileRange> fileRanges = new ArrayList<>();
fileRanges.add(FileRange.createFileRange(100, 500));
fileRanges.add(FileRange.createFileRange(600, 500));
return fileRanges;
}

/**
* Validate that exceptions must be thrown during a vectored
* read operation with specific input ranges.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,6 @@ public int maxReadSizeForVectorReads() {
@Override
public void readVectored(List<? extends FileRange> ranges,
IntFunction<ByteBuffer> allocate) throws IOException {

LOG.debug("Starting vectored read on path {} for ranges {} ", pathStr, ranges);
checkNotClosed();
if (stopVectoredIOOperations.getAndSet(false)) {
Expand All @@ -978,6 +977,7 @@ public void readVectored(List<? extends FileRange> ranges,

if (isOrderedDisjoint(sortedRanges, 1, minSeekForVectorReads())) {
LOG.debug("Not merging the ranges as they are disjoint");
streamStatistics.readVectoredOperationStarted(sortedRanges.size(), sortedRanges.size());
for (FileRange range: sortedRanges) {
ByteBuffer buffer = allocate.apply(range.getLength());
unboundedThreadPool.submit(() -> readSingleRange(range, buffer));
Expand All @@ -987,6 +987,7 @@ public void readVectored(List<? extends FileRange> ranges,
List<CombinedFileRange> combinedFileRanges = mergeSortedRanges(sortedRanges,
1, minSeekForVectorReads(),
maxReadSizeForVectorReads());
streamStatistics.readVectoredOperationStarted(sortedRanges.size(), combinedFileRanges.size());
LOG.debug("Number of original ranges size {} , Number of combined ranges {} ",
ranges.size(), combinedFileRanges.size());
for (CombinedFileRange combinedFileRange: combinedFileRanges) {
Expand Down Expand Up @@ -1088,6 +1089,7 @@ private void drainUnnecessaryData(S3ObjectInputStream objectContent, long drainQ
}
drainBytes += readCount;
}
streamStatistics.readVectoredBytesDiscarded(drainBytes);
LOG.debug("{} bytes drained from stream ", drainBytes);
}

Expand Down Expand Up @@ -1168,6 +1170,8 @@ private void populateBuffer(int length,
} else {
readByteArray(objectContent, buffer.array(), 0, length);
}
// update io stats.
incrementBytesRead(length);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,10 @@ private final class InputStreamStatistics
private final AtomicLong readOperations;
private final AtomicLong readFullyOperations;
private final AtomicLong seekOperations;
private final AtomicLong readVectoredOperations;
private final AtomicLong bytesDiscardedInVectoredIO;
private final AtomicLong readVectoredIncomingRanges;
private final AtomicLong readVectoredCombinedRanges;

/** Bytes read by the application and any when draining streams . */
private final AtomicLong totalBytesRead;
Expand Down Expand Up @@ -836,6 +840,10 @@ private InputStreamStatistics(
StreamStatisticNames.STREAM_READ_SEEK_BYTES_SKIPPED,
StreamStatisticNames.STREAM_READ_TOTAL_BYTES,
StreamStatisticNames.STREAM_READ_UNBUFFERED,
StreamStatisticNames.STREAM_READ_VECTORED_COMBINED_RANGES,
StreamStatisticNames.STREAM_READ_VECTORED_INCOMING_RANGES,
StreamStatisticNames.STREAM_READ_VECTORED_OPERATIONS,
StreamStatisticNames.STREAM_READ_VECTORED_READ_BYTES_DISCARDED,
StreamStatisticNames.STREAM_READ_VERSION_MISMATCHES)
.withGauges(STREAM_READ_GAUGE_INPUT_POLICY)
.withDurationTracking(ACTION_HTTP_GET_REQUEST,
Expand Down Expand Up @@ -872,6 +880,14 @@ private InputStreamStatistics(
StreamStatisticNames.STREAM_READ_OPERATIONS_INCOMPLETE);
readOperations = st.getCounterReference(
StreamStatisticNames.STREAM_READ_OPERATIONS);
readVectoredOperations = st.getCounterReference(
StreamStatisticNames.STREAM_READ_VECTORED_OPERATIONS);
bytesDiscardedInVectoredIO = st.getCounterReference(
StreamStatisticNames.STREAM_READ_VECTORED_READ_BYTES_DISCARDED);
readVectoredIncomingRanges = st.getCounterReference(
StreamStatisticNames.STREAM_READ_VECTORED_INCOMING_RANGES);
readVectoredCombinedRanges = st.getCounterReference(
StreamStatisticNames.STREAM_READ_VECTORED_COMBINED_RANGES);
readFullyOperations = st.getCounterReference(
StreamStatisticNames.STREAM_READ_FULLY_OPERATIONS);
seekOperations = st.getCounterReference(
Expand Down Expand Up @@ -1017,6 +1033,19 @@ public void readOperationCompleted(int requested, int actual) {
}
}

@Override
public void readVectoredOperationStarted(int numIncomingRanges,
int numCombinedRanges) {
readVectoredIncomingRanges.addAndGet(numIncomingRanges);
readVectoredCombinedRanges.addAndGet(numCombinedRanges);
readVectoredOperations.incrementAndGet();
}

@Override
public void readVectoredBytesDiscarded(int discarded) {
bytesDiscardedInVectoredIO.addAndGet(discarded);
}

/**
* {@code close()} merges the stream statistics into the filesystem's
* instrumentation instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ void streamClose(boolean abortedConnection,
*/
void readOperationCompleted(int requested, int actual);

/**
* A vectored read operation has started..
* @param numIncomingRanges number of input ranges.
* @param numCombinedRanges number of combined ranges.
*/
void readVectoredOperationStarted(int numIncomingRanges,
int numCombinedRanges);

/**
* Number of bytes discarded during vectored read.
* @param discarded discarded bytes during vectored read.
*/
void readVectoredBytesDiscarded(int discarded);

@Override
void close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ public void readOperationCompleted(final int requested, final int actual) {

}

@Override
public void readVectoredOperationStarted(int numIncomingRanges,
int numCombinedRanges) {

}

@Override
public void readVectoredBytesDiscarded(int discarded) {

}

@Override
public void close() {

Expand Down
Loading