Skip to content
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

HDDS-10338. Implement a Client Datanode API to stream a block #6613

Draft
wants to merge 90 commits into
base: master
Choose a base branch
from

Conversation

chungen0126
Copy link
Contributor

@chungen0126 chungen0126 commented Apr 30, 2024

What changes were proposed in this pull request?

To reduce round trips between the Client and Datanode for reading a block, we nee a new API to read.

Client -> block(offset, length) -> Datanode
Client <- chunkN <- Datanode
Client <- chunkN+1 <- Datanode
..
Client <-chunkLast <- Datanode

This is using the ability of gRPC to send bidirectional traffic such that the server can pipeline the chunks to the client without waiting for ReadChunk API calls. This also avoids the client from creating multiple Chunk Stream Clients and should simplify the read path on the client side by a bit.

Please describe your PR in detail:

  • Add a new logic at both client and server side to read block as streaming chunks.
  • Add a new StreamBlockInput at client side called from KeyInputStream to read a block from the container.
  • Add unit tests and integration tests for `StreamBlockInput.
  • Add a new version in datanode for compatibilities, while new client reading blocks from old server, it will fallback and read blocks by BlockInputStream.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-10338

How was this patch tested?

There are existed test for reading data.

@@ -458,4 +485,77 @@ private static ContainerCommandRequestProto createContainerRequest(
.setContainerID(containerID).setPipelineID(UUID.randomUUID().toString())
.build();
}

@Test
public void testReadBlock() throws IOException {
Copy link
Contributor

@ChenSammi ChenSammi Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add add an end to end case, to test read an empty file with an empty block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add testReadEmptyBlock in the TestStreamBlockInputStream to test read an empty block.

@ChenSammi
Copy link
Contributor

ChenSammi commented Dec 4, 2024

@chungen0126 , thanks for the quick patch updating. I will try to finish the review this week.

Copy link
Contributor

@ptlrs ptlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @chungen0126. I have a few comments.

Comment on lines +56 to +57
private static final int CHUNK_SIZE = 100;
private static final int BYTES_PER_CHECKSUM = 20;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some tests which cover the conditions where BYTES_PER_CHECKSUM is equal-to and greater than CHUNK_SIZE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to add this test case. Logically, BYTES_PER_CHECKSUM should be smaller than CHUNK_SIZE. Otherwise, a single chunk file cannot be verified.

@ptlrs
Copy link
Contributor

ptlrs commented Dec 21, 2024

Test conducted on our cluster(3DN / HDD / 10 Gigabit network) shows this improvement can boost read speed by at least 30%.

It can be seen that for 1GB file reading, streaming reading can reduce the reading time by about 30%.

Hi @chungen0126 @guohao-rosicky, do we know how much of an improvement is being seen for files smaller than 1GB?

@fenixjin
Copy link

fenixjin commented Jan 7, 2025

Test conducted on our cluster(3DN / HDD / 10 Gigabit network) shows this improvement can boost read speed by at least 30%.

It can be seen that for 1GB file reading, streaming reading can reduce the reading time by about 30%.

Hi @chungen0126 @guohao-rosicky, do we know how much of an improvement is being seen for files smaller than 1GB?

@ptlrs
conducted test using freon on the latest version of this pr, hardware is 3DN / HDD / 10 Gigabit network, tested file sizes are 1GB 128MB 16MB 2MB 256KB. there is an index bug when verifying checksum, tests were conducted after fixing it.
here are the redunctions in mean read time given by freon:

  • 1GB: 7%
  • 128MB: 10%
  • 16MB 8%
  • 2MB 10%
  • 256KB 8%

further tests were conducted with verifying checksum skipped, it turns out checksum have a substantial impact on read time.
when testing using freon on 1GB file, turning on checksum caused read time to increase from around 3700ms to 5000ms.
with checksum off, the read time reduction of stream block compared with current read method(checksum also off) is:

  • 1GB: 30%
  • 128MB: 21%
  • 16MB: 11%
  • 2MB: -5.6% (chunk size is 4MB)

@guohao-rosicky
Copy link
Contributor

Can you resolve the code conflict? @chungen0126

@adoroszlai adoroszlai self-assigned this Feb 14, 2025
@adoroszlai adoroszlai marked this pull request as draft February 14, 2025 10:13
@adoroszlai
Copy link
Contributor

Temporarily converted to draft and assigned to myself, to resolve conflicts.

@chungen0126
Copy link
Contributor Author

Thanks @adoroszlai for fixing the conflicts. I was just about to address it.

@adoroszlai adoroszlai removed their assignment Feb 15, 2025
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.

10 participants