HDDS-13660. Ozone client support readVectored.#9402
Conversation
|
Thanks @ashishkumar50 for the patch. I have ported the corresponding contract test from Hadoop, which shows that some input validation is missing (negative length and offset, overlapping ranges, same ranges). Please feel free to pick it from adoroszlai@ee11cf3 and include in this PR. https://github.com/adoroszlai/ozone/actions/runs/19905480757/job/57061761264#step:13:5599 |
(cherry picked from commit ee11cf3)
|
@adoroszlai Thanks for the review, handled comments. |
| (offset, buffer) -> readRangeData(offset, buffer, initialPosition)); | ||
| } finally { | ||
| // Restore position | ||
| synchronized (this) { |
There was a problem hiding this comment.
what would happen in case of concurrent readVectored() calls?
There was a problem hiding this comment.
Synchronized now to avoid race condition in same concurrent stream reads.
| }); | ||
| } finally { | ||
| // Restore position | ||
| synchronized (this) { |
There was a problem hiding this comment.
what would happen in case of concurrent readVectored() calls?
There was a problem hiding this comment.
Synchronized now to avoid race condition in same concurrent stream reads.
|
@chungen0126 @jojochuang @yandrey321 please take a look |
chungen0126
left a comment
There was a problem hiding this comment.
Thanks for @ashishkumar50 the patch. Are there plans to optimize read vector further? The current implementation doesn't seem to fully support fully parallel reading for different ranges yet. I also added some comments.
| ); | ||
|
|
||
| // Restore position | ||
| seek(initialPosition); |
There was a problem hiding this comment.
I'm wondering if the seek to initialPosition is necessary here? Since the offset changes asynchronously, restoring it at this point might not work correctly. It seems like readRangeData already handles the position restoration correctly.
| ); | ||
|
|
||
| // Restore position before returning from method | ||
| seek(initialPosition); |
There was a problem hiding this comment.
Same comment as above.
|
This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days. |
|
@ashishkumar50 please take a look at @chungen0126's comments. |
yandrey321
left a comment
There was a problem hiding this comment.
These changes add a lot of synchronization on IO path, is there a write up that justify these changes? Are there any performance benchmark results that measure performance impact of these changes?
| * @apiNote This method is synchronized to prevent race conditions from | ||
| * concurrent readVectored() calls on the same stream instance. | ||
| */ | ||
| public synchronized void readVectored( |
There was a problem hiding this comment.
does it need to be syncronized?
| */ | ||
| private void readRangeData(long offset, ByteBuffer buffer, long initialPosition) | ||
| throws IOException { | ||
| synchronized (this) { |
There was a problem hiding this comment.
is there a reason for not allowing concurrent reads?
| */ | ||
| @Override | ||
| public int read(long position, ByteBuffer buf) throws IOException { | ||
| public synchronized int read(long position, ByteBuffer buf) throws IOException { |
There was a problem hiding this comment.
what is the reason for adding syncrhonized here?
| */ | ||
| @Override | ||
| public void readFully(long position, ByteBuffer buf) throws IOException { | ||
| public synchronized void readFully(long position, ByteBuffer buf) throws IOException { |
There was a problem hiding this comment.
what is the reason for adding syncrhonized here?
| * concurrent readVectored() calls on the same stream instance. | ||
| */ | ||
| @Override | ||
| public synchronized void readVectored(List<? extends FileRange> ranges, |
There was a problem hiding this comment.
does it need to be synchronized?
|
This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days. |
|
Thank you for your contribution. This PR is being closed due to inactivity. Please contact a maintainer if you would like to reopen it. |
|
Hi @ashishkumar50 @yandrey321 @adoroszlai @jojochuang , just checking in to see if this PR is still active? I’ve been looking into I'm planning to create two subtasks to track |
|
Thanks @chungen0126 for checking. I guess this was dropped due to lack of time. It would be great if you could continue work on |
|
Hi all, I've submitted a PR to implement positional reads in Along with the implementation, I've written a microbenchmark for readVectored on this branch to verify the performance gains on the client side from reducing lock contention. Benchmark Setup:Platform: Local macOS Test Scenarios:Consecutive range pattern: 20 ranges, 1 MB each Results:Plaintext --- Pattern: Random Ranges --- --- Pattern: Sparse Ranges --- Current Progress & Next Steps:Currently, this branch only implements positional read for general reads. While working on BlockStreamRead, I ran into a few bugs. Therefore, I will follow up with another PR to implement positional read for BlockStreamRead later. |
We also need to evaluate how it would work with read streaming, I can pick one some of these tasks. |
What changes were proposed in this pull request?
Ozone client support readVectored which allows reading multiple file ranges in parallel.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13660
How was this patch tested?
Tests are added