-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19622: [ABFS][ReadAheadV2] Implement Read Buffer Manager V2 with improved aggressiveness #7832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-19622: [ABFS][ReadAheadV2] Implement Read Buffer Manager V2 with improved aggressiveness #7832
Changes from all commits
37898b4
28cb97f
3ee60df
7670846
6a68686
9552072
0c368d8
a894d06
ad8190b
b4d8183
f5883d0
d258d90
2444f92
c17f298
a6064ef
12d56c4
0376544
e794fd4
a203e3d
08ea09b
28a2c82
cdab7ea
706d7d6
cd8a2b9
a0f8021
7990ab0
98902b0
1da6218
088f425
c3acf96
a214133
3f29a03
b34cf4b
cfb6b4b
88692e3
5e03a9b
1ba5320
56f97b3
da3661a
124925a
1667de1
c81c082
a0f8b0b
c7f986e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,12 +153,19 @@ public final class FileSystemConfigurations { | |
|
|
||
| public static final boolean DEFAULT_ENABLE_READAHEAD = true; | ||
| public static final boolean DEFAULT_ENABLE_READAHEAD_V2 = false; | ||
| public static final int DEFAULT_READAHEAD_V2_MIN_THREAD_POOL_SIZE = -1; | ||
| public static final boolean DEFAULT_ENABLE_READAHEAD_V2_DYNAMIC_SCALING = false; | ||
| public static final int DEFAULT_READAHEAD_V2_MIN_THREAD_POOL_SIZE = 8; | ||
| public static final int DEFAULT_READAHEAD_V2_MAX_THREAD_POOL_SIZE = -1; | ||
| public static final int DEFAULT_READAHEAD_V2_MIN_BUFFER_POOL_SIZE = -1; | ||
| public static final int DEFAULT_READAHEAD_V2_MIN_BUFFER_POOL_SIZE = 16; | ||
| public static final int DEFAULT_READAHEAD_V2_MAX_BUFFER_POOL_SIZE = -1; | ||
| public static final int DEFAULT_READAHEAD_V2_EXECUTOR_SERVICE_TTL_MILLIS = 3_000; | ||
| public static final int DEFAULT_READAHEAD_V2_CPU_MONITORING_INTERVAL_MILLIS = 6_000; | ||
| public static final int DEFAULT_READAHEAD_V2_THREAD_POOL_UPSCALE_PERCENTAGE = 20; | ||
| public static final int DEFAULT_READAHEAD_V2_THREAD_POOL_DOWNSCALE_PERCENTAGE = 30; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken |
||
| public static final int DEFAULT_READAHEAD_V2_MEMORY_MONITORING_INTERVAL_MILLIS = 6_000; | ||
| public static final int DEFAULT_READAHEAD_V2_EXECUTOR_SERVICE_TTL_MILLIS = 6_000; | ||
| public static final int DEFAULT_READAHEAD_V2_CACHED_BUFFER_TTL_MILLIS = 6_000; | ||
| public static final int DEFAULT_READAHEAD_V2_CPU_USAGE_THRESHOLD_PERCENTAGE = 50; | ||
| public static final int DEFAULT_READAHEAD_V2_MEMORY_USAGE_THRESHOLD_PERCENTAGE = 50; | ||
|
|
||
| public static final String DEFAULT_FS_AZURE_USER_AGENT_PREFIX = EMPTY_STRING; | ||
| public static final String DEFAULT_VALUE_UNKNOWN = "UNKNOWN"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ | |
| public static final int FOOTER_SIZE = 16 * ONE_KB; | ||
| public static final int MAX_OPTIMIZED_READ_ATTEMPTS = 2; | ||
|
|
||
| private int readAheadBlockSize; | ||
| private final int readAheadBlockSize; | ||
| private final AbfsClient client; | ||
| private final Statistics statistics; | ||
| private final String path; | ||
|
|
@@ -132,7 +132,7 @@ | |
|
|
||
| /** ABFS instance to be held by the input stream to avoid GC close. */ | ||
| private final BackReference fsBackRef; | ||
| private ReadBufferManager readBufferManager; | ||
| private final ReadBufferManager readBufferManager; | ||
|
|
||
| public AbfsInputStream( | ||
| final AbfsClient client, | ||
|
|
@@ -184,10 +184,13 @@ | |
| * If none of the V1 and V2 are enabled, then no read ahead will be done. | ||
| */ | ||
| if (readAheadV2Enabled) { | ||
| LOG.debug("ReadBufferManagerV2 not yet implemented, defaulting to ReadBufferManagerV1"); | ||
| ReadBufferManagerV2.setReadBufferManagerConfigs( | ||
| readAheadBlockSize, client.getAbfsConfiguration()); | ||
| readBufferManager = ReadBufferManagerV2.getBufferManager(); | ||
| } else { | ||
| ReadBufferManagerV1.setReadBufferManagerConfigs(readAheadBlockSize); | ||
| readBufferManager = ReadBufferManagerV1.getBufferManager(); | ||
| } | ||
| ReadBufferManagerV1.setReadBufferManagerConfigs(readAheadBlockSize); | ||
| readBufferManager = ReadBufferManagerV1.getBufferManager(); | ||
|
|
||
| if (streamStatistics != null) { | ||
| ioStatistics = streamStatistics.getIOStatistics(); | ||
|
|
@@ -530,7 +533,7 @@ | |
| while (numReadAheads > 0 && nextOffset < contentLength) { | ||
| LOG.debug("issuing read ahead requestedOffset = {} requested size {}", | ||
| nextOffset, nextSize); | ||
| readBufferManager.queueReadAhead(this, nextOffset, (int) nextSize, | ||
| getReadBufferManager().queueReadAhead(this, nextOffset, (int) nextSize, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs changes in constructor to return an instance of readbuffermanager v2 if enabled
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken |
||
| new TracingContext(readAheadTracingContext)); | ||
| nextOffset = nextOffset + nextSize; | ||
| numReadAheads--; | ||
|
|
@@ -539,7 +542,7 @@ | |
| } | ||
|
|
||
| // try reading from buffers first | ||
| receivedBytes = readBufferManager.getBlock(this, position, length, b); | ||
| receivedBytes = getReadBufferManager().getBlock(this, position, length, b); | ||
| bytesFromReadAhead += receivedBytes; | ||
| if (receivedBytes > 0) { | ||
| incrementReadOps(); | ||
|
|
@@ -743,8 +746,8 @@ | |
| public synchronized void close() throws IOException { | ||
| LOG.debug("Closing {}", this); | ||
| closed = true; | ||
| if (readBufferManager != null) { | ||
| readBufferManager.purgeBuffersForStream(this); | ||
| if (getReadBufferManager() != null) { | ||
| getReadBufferManager().purgeBuffersForStream(this); | ||
| } | ||
| buffer = null; // de-reference the buffer so it can be GC'ed sooner | ||
| if (contextEncryptionAdapter != null) { | ||
|
|
@@ -805,7 +808,7 @@ | |
| */ | ||
| @VisibleForTesting | ||
| public boolean isReadAheadEnabled() { | ||
| return (readAheadEnabled || readAheadV2Enabled) && readBufferManager != null; | ||
| return (readAheadEnabled || readAheadV2Enabled) && getReadBufferManager() != null; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
|
|
@@ -823,6 +826,10 @@ | |
| return inputStreamId; | ||
| } | ||
|
|
||
| public String getETag() { | ||
| return eTag; | ||
| } | ||
|
|
||
| /** | ||
| * Getter for AbfsInputStreamStatistics. | ||
| * | ||
|
|
@@ -875,7 +882,7 @@ | |
| } | ||
|
|
||
| @VisibleForTesting | ||
| public boolean shouldAlwaysReadBufferSize() { | ||
|
Check failure on line 885 in hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java
|
||
| return alwaysReadBufferSize; | ||
| } | ||
|
|
||
|
|
@@ -920,11 +927,20 @@ | |
| return this.limit; | ||
| } | ||
|
|
||
| boolean isFirstRead() { | ||
| return this.firstRead; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| BackReference getFsBackRef() { | ||
| return fsBackRef; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| ReadBufferManager getReadBufferManager() { | ||
| return readBufferManager; | ||
| } | ||
|
|
||
| @Override | ||
| public int minSeekForVectorReads() { | ||
| return S_128K; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some variable you have used Persentage and for percent, we should keep it consistent across all places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken