Skip to content

HDFS-17975. HDFS Client-Side Block Prefetch to Improve Large Sequential Read Throughput - #8716

Open
rdhabalia wants to merge 1 commit into
apache:trunkfrom
rdhabalia:prefetch-parallel-read
Open

HDFS-17975. HDFS Client-Side Block Prefetch to Improve Large Sequential Read Throughput#8716
rdhabalia wants to merge 1 commit into
apache:trunkfrom
rdhabalia:prefetch-parallel-read

Conversation

@rdhabalia

Copy link
Copy Markdown

Description of PR

Large sequential scans, such as analytics, bulk copies, and
columnar readers, open a DFSInputStream and read a file end-to-end.

Today, each block is fetched synchronously:

  1. The reader thread opens a BlockReader.
  2. It waits for the DataNode/network round trip.
  3. It drains the block.
  4. It repeats the process for the next block.

The per-block open latency and single-block-at-a-time pipeline leave the
client CPU idle while waiting on I/O and cap throughput well below what the
DataNodes and network can deliver.

This change adds an opt-in, client-side read-ahead prefetcher that fetches
blocks ahead of the reader's cursor using a shared background thread pool.
By the time the reader reaches a prefetched block, the block is already
resident in memory and can be served as an in-memory copy.

Approach

BlockPrefetcher

  • Introduces a new BlockPrefetcher that maintains a bounded, sliding window
    of block-sized buffers ahead of the current read position.
  • Blocks are filled in chunks using a shared, JVM-wide daemon thread pool.
  • The thread pool uses:
    • SynchronousQueue
    • AbortPolicy
  • When all workers are busy, a prefetch submission is rejected and skipped
    rather than blocking the foreground reader thread.

DFSInputStream Integration

  • DFSInputStream.read(byte[]) and read(ByteBuffer) first attempt to serve
    data from the prefetch cache.
  • On a cache hit:
    • The read position is advanced.
    • The stateful synchronous reader is invalidated.
    • Read statistics are updated exactly as they are on the direct path.
    • Locality is preserved across short-circuit, local, and remote reads.
  • On a cache miss:
    • The normal synchronous read path is used.
    • Block locations are cached for subsequent prefetch operations.

Prefetch Safety and Correctness

  • Prefetch operates entirely using cached block locations.
  • It never issues a getBlockLocations RPC.
  • It does not mutate foreground retry state while a foreground read may hold
    infoLock.
  • The following cases are excluded for correctness:
    • Non-uniform block sizes
    • Striped (EC) files
    • Under-construction files
    • Single-block files

Metrics and Observability

  • A shared, opt-in scheduled task periodically logs per-stream cache
    hit/miss ratios at INFO level.
  • Metrics logging occurs only when metrics logging is enabled.

Global Memory Budget

  • A global byte budget bounds the total memory held by all prefetch buffers
    across the JVM.
  • The budget grows to the largest configured value across clients.
  • Memory is strictly reserved and released on a per-stream basis.

Configuration

All configuration is client-side. The feature is disabled by default.

Configuration Description
dfs.client.prefetch.enabled Enables client-side read-ahead prefetching
dfs.client.prefetch.size Per-stream read-ahead window
dfs.client.prefetch.max.bytes JVM-wide prefetch memory cap
dfs.client.prefetch.chunk.size Prefetch fill granularity
dfs.client.prefetch.threads Shared prefetch worker thread count
dfs.client.prefetch.threadpool.size Shared prefetch worker thread pool size
dfs.client.prefetch.ttl.ms Buffer time-to-live
dfs.client.prefetch.metrics.log.enabled Enables periodic cache hit-ratio logging

Results

A single-client sequential read benchmark was run with:

  • File size: 10 GB
  • Block size: 512 MB
  • Prefetch threads: 5
  • Prefetch window: ~3 GB

Performance

Metric Result
Baseline throughput 406.8 MB/s
Prefetch throughput 1,419.5 MB/s
Average improvement ~3.49x
Peak throughput ~1.58 GB/s
Cache hit ratio ~81%

The feature is off by default and has no impact on the read path until
explicitly enabled.

How was this patch tested?

Tested by newly added unit test

For code changes:

  • Does the title of this PR start with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: Have the integration tests been executed and the endpoint
    declared according to the connector-specific documentation? Note: Automated CI
    testing doesn't cover all cases so manual testing with cloud storage is still
    required.
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

AI Tooling

If an AI tool was used:

@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 1s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 xmllint 0m 0s xmllint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 2m 21s Maven dependency ordering for branch
+1 💚 mvninstall 44m 15s trunk passed
+1 💚 compile 5m 23s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 compile 5m 48s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 checkstyle 2m 15s trunk passed
+1 💚 mvnsite 3m 22s trunk passed
+1 💚 javadoc 2m 41s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javadoc 2m 41s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 spotbugs 7m 53s trunk passed
+1 💚 shadedclient 31m 34s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 26s Maven dependency ordering for patch
-1 ❌ mvninstall 0m 29s /patch-mvninstall-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
-1 ❌ compile 1m 5s /patch-compile-hadoop-hdfs-project-jdkUbuntu-21.0.12+8-1-24.04-Ubuntu.txt hadoop-hdfs-project in the patch failed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu.
-1 ❌ javac 1m 5s /patch-compile-hadoop-hdfs-project-jdkUbuntu-21.0.12+8-1-24.04-Ubuntu.txt hadoop-hdfs-project in the patch failed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu.
-1 ❌ compile 1m 4s /patch-compile-hadoop-hdfs-project-jdkUbuntu-17.0.20+8-1-24.04-Ubuntu.txt hadoop-hdfs-project in the patch failed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu.
-1 ❌ javac 1m 4s /patch-compile-hadoop-hdfs-project-jdkUbuntu-17.0.20+8-1-24.04-Ubuntu.txt hadoop-hdfs-project in the patch failed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu.
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 1m 41s /results-checkstyle-hadoop-hdfs-project.txt hadoop-hdfs-project: The patch generated 32 new + 109 unchanged - 0 fixed = 141 total (was 109)
-1 ❌ mvnsite 0m 32s /patch-mvnsite-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
-1 ❌ javadoc 0m 39s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-client-jdkUbuntu-21.0.12+8-1-24.04-Ubuntu.txt hadoop-hdfs-client in the patch failed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu.
-1 ❌ javadoc 0m 30s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-21.0.12+8-1-24.04-Ubuntu.txt hadoop-hdfs in the patch failed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu.
-1 ❌ javadoc 0m 38s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-client-jdkUbuntu-17.0.20+8-1-24.04-Ubuntu.txt hadoop-hdfs-client in the patch failed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu.
-1 ❌ javadoc 0m 31s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-17.0.20+8-1-24.04-Ubuntu.txt hadoop-hdfs in the patch failed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu.
-1 ❌ spotbugs 0m 31s /patch-spotbugs-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
-1 ❌ shadedclient 11m 40s patch has errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 2m 38s hadoop-hdfs-client in the patch passed.
-1 ❌ unit 0m 32s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
+1 💚 asflicense 0m 32s The patch does not generate ASF License warnings.
136m 53s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/1/artifact/out/Dockerfile
GITHUB PR #8716
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets xmllint
uname Linux 1840b350ba96 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 8f10b7e
Default Java Ubuntu-17.0.20+8-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12+8-1-24.04-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20+8-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/1/testReport/
Max. process+thread count 610 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/1/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@rdhabalia
rdhabalia force-pushed the prefetch-parallel-read branch 2 times, most recently from 2a39e3f to 9b42d55 Compare September 5, 2026 04:25
@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 2s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+0 🆗 xmllint 0m 1s xmllint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 2m 5s Maven dependency ordering for branch
+1 💚 mvninstall 43m 7s trunk passed
+1 💚 compile 5m 23s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 compile 5m 49s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 checkstyle 2m 11s trunk passed
+1 💚 mvnsite 3m 22s trunk passed
+1 💚 javadoc 2m 43s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javadoc 2m 41s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 spotbugs 8m 5s trunk passed
+1 💚 shadedclient 32m 20s branch has no errors when building and testing our client artifacts.
-0 ⚠️ patch 32m 51s Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 28s Maven dependency ordering for patch
+1 💚 mvninstall 2m 10s the patch passed
+1 💚 compile 4m 53s the patch passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javac 4m 53s the patch passed
+1 💚 compile 5m 24s the patch passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 javac 5m 24s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 1m 47s /results-checkstyle-hadoop-hdfs-project.txt hadoop-hdfs-project: The patch generated 40 new + 109 unchanged - 0 fixed = 149 total (was 109)
+1 💚 mvnsite 2m 56s the patch passed
-1 ❌ javadoc 0m 39s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-client-jdkUbuntu-21.0.12+8-1-24.04-Ubuntu.txt hadoop-hdfs-client in the patch failed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu.
-1 ❌ javadoc 0m 47s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-client-jdkUbuntu-17.0.20+8-1-24.04-Ubuntu.txt hadoop-hdfs-client in the patch failed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu.
+1 💚 spotbugs 8m 6s the patch passed
+1 💚 shadedclient 32m 56s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 2m 39s hadoop-hdfs-client in the patch passed.
-1 ❌ unit 303m 50s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 55s The patch does not generate ASF License warnings.
476m 57s
Reason Tests
Failed junit tests hadoop.tools.TestHdfsConfigFields
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/2/artifact/out/Dockerfile
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets xmllint
uname Linux 433c7b07a6aa 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 706d4dc
Default Java Ubuntu-17.0.20+8-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12+8-1-24.04-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20+8-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/2/testReport/
Max. process+thread count 3195 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/2/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 10s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 xmllint 0m 0s xmllint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 2m 10s Maven dependency ordering for branch
+1 💚 mvninstall 46m 14s trunk passed
+1 💚 compile 5m 50s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 compile 6m 13s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 checkstyle 2m 10s trunk passed
+1 💚 mvnsite 3m 12s trunk passed
+1 💚 javadoc 2m 34s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javadoc 2m 32s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 spotbugs 7m 37s trunk passed
+1 💚 shadedclient 33m 25s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 29s Maven dependency ordering for patch
+1 💚 mvninstall 2m 30s the patch passed
+1 💚 compile 5m 50s the patch passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javac 5m 50s the patch passed
+1 💚 compile 6m 17s the patch passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 javac 6m 17s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 1m 48s /results-checkstyle-hadoop-hdfs-project.txt hadoop-hdfs-project: The patch generated 40 new + 109 unchanged - 0 fixed = 149 total (was 109)
+1 💚 mvnsite 2m 46s the patch passed
+1 💚 javadoc 1m 44s the patch passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javadoc 1m 49s the patch passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 spotbugs 8m 15s the patch passed
+1 💚 shadedclient 37m 13s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 2m 47s hadoop-hdfs-client in the patch passed.
-1 ❌ unit 300m 40s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 47s The patch does not generate ASF License warnings.
484m 55s
Reason Tests
Failed junit tests hadoop.hdfs.server.namenode.ha.TestBootstrapStandby
hadoop.tools.TestHdfsConfigFields
hadoop.hdfs.server.namenode.ha.TestStandbyCheckpoints
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/3/artifact/out/Dockerfile
GITHUB PR #8716
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets xmllint
uname Linux 3384f607c02f 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 9b42d55
Default Java Ubuntu-17.0.20+8-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12+8-1-24.04-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20+8-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/3/testReport/
Max. process+thread count 3119 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/3/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@rdhabalia
rdhabalia force-pushed the prefetch-parallel-read branch from 9b42d55 to 6081187 Compare September 6, 2026 07:04
@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 19m 34s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 xmllint 0m 0s xmllint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 1m 52s Maven dependency ordering for branch
+1 💚 mvninstall 42m 44s trunk passed
+1 💚 compile 5m 26s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 compile 5m 49s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 checkstyle 2m 11s trunk passed
+1 💚 mvnsite 3m 23s trunk passed
+1 💚 javadoc 2m 42s trunk passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javadoc 2m 40s trunk passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 spotbugs 7m 48s trunk passed
+1 💚 shadedclient 31m 41s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 28s Maven dependency ordering for patch
+1 💚 mvninstall 2m 13s the patch passed
+1 💚 compile 4m 53s the patch passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javac 4m 53s the patch passed
+1 💚 compile 5m 23s the patch passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 javac 5m 23s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 1m 38s /results-checkstyle-hadoop-hdfs-project.txt hadoop-hdfs-project: The patch generated 32 new + 109 unchanged - 0 fixed = 141 total (was 109)
+1 💚 mvnsite 2m 23s the patch passed
+1 💚 javadoc 1m 37s the patch passed with JDK Ubuntu-21.0.12+8-1-24.04-Ubuntu
+1 💚 javadoc 1m 44s the patch passed with JDK Ubuntu-17.0.20+8-1-24.04-Ubuntu
+1 💚 spotbugs 7m 17s the patch passed
+1 💚 shadedclient 30m 51s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 2m 42s hadoop-hdfs-client in the patch passed.
-1 ❌ unit 285m 47s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 48s The patch does not generate ASF License warnings.
472m 36s
Reason Tests
Failed junit tests hadoop.tools.TestHdfsConfigFields
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/4/artifact/out/Dockerfile
GITHUB PR #8716
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets xmllint
uname Linux 695bbc6afa35 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 6081187
Default Java Ubuntu-17.0.20+8-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12+8-1-24.04-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20+8-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/4/testReport/
Max. process+thread count 3019 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/4/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@rdhabalia
rdhabalia force-pushed the prefetch-parallel-read branch from 6081187 to f037381 Compare September 6, 2026 21:00
@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 0s Docker mode activated.
-1 ❌ patch 0m 21s #8716 does not apply to trunk. Rebase required? Wrong Branch? See https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute for help.
Subsystem Report/Notes
GITHUB PR #8716
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8716/5/console
versions git=2.34.1
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

Motivation
----------
Large sequential scans (analytics/ML training, bulk copies, columnar
readers) open a DFSInputStream and read a file end-to-end. Each block is
fetched synchronously: the reader thread opens a BlockReader, waits for
the DataNode/network round trip, drains the block, then repeats for the
next block. The per-block open latency and single-block-at-a-time
pipeline leave the client CPU idle while waiting on I/O and cap
throughput well below what the DataNodes and network can deliver.

This change adds an opt-in, client-side read-ahead prefetcher that
fetches blocks ahead of the reader's cursor on a shared background
thread pool, so that by the time the reader reaches a block it is
already resident in memory and served as an in-memory copy.

Approach
--------
- BlockPrefetcher (new) maintains a bounded, sliding window of
  block-sized buffers ahead of the current read position. Blocks are
  filled in chunks by a shared, JVM-wide daemon thread pool with a
  SynchronousQueue + AbortPolicy, so that when all workers are busy a
  prefetch submission is rejected and skipped rather than run on (and
  block) the foreground reader thread.
- DFSInputStream.read(byte[]) and read(ByteBuffer) first try to serve
  from the prefetch cache; on a hit the position is advanced, the
  stateful synchronous reader is invalidated, and read statistics are
  updated exactly as on the direct path (locality-aware: short-circuit
  / local / remote). On a miss it falls back to the normal synchronous
  read, which also caches block locations for a later prefetch.
- Prefetch runs entirely off cached block locations; it never issues a
  getBlockLocations RPC or mutates foreground retry state while a
  foreground read may hold infoLock. Non-uniform block sizes, striped
  (EC) files, under-construction files and single-block files are
  excluded for correctness.
- A shared, opt-in scheduled task logs per-stream cache hit/miss ratios
  at INFO (only when metrics logging is enabled) for observability.
- A global byte budget bounds total memory held across all prefetch
  buffers in the JVM; it grows to the largest configured value across
  clients and is strictly reserved/released per stream.

Configuration (all client-side; feature disabled by default)
------------------------------------------------------------
  dfs.client.prefetch.enabled            (default false)
  dfs.client.prefetch.size               per-stream read-ahead window
  dfs.client.prefetch.max.bytes          JVM-wide prefetch memory cap
  dfs.client.prefetch.chunk.size         fill granularity
  dfs.client.prefetch.threads /
  dfs.client.prefetch.threadpool.size    shared prefetch worker threads
  dfs.client.prefetch.ttl.ms             buffer time-to-live
  dfs.client.prefetch.metrics.log.enabled periodic hit-ratio logging

Results
-------
On a single-client sequential read benchmark (10 GB files, 512 MB
blocks, 5 prefetch threads, ~3 GB prefetch window) average read
throughput improved ~3.49x (406.8 MB/s -> 1419.5 MB/s), peaking at
~1.58 GB/s, with a cache hit ratio of ~81%. The feature is off by
default and has no effect on the read path until enabled.
@rdhabalia
rdhabalia force-pushed the prefetch-parallel-read branch from f037381 to ad3c414 Compare September 6, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants