Skip to content

Conversation

@szetszwo
Copy link
Contributor

@szetszwo szetszwo commented Mar 6, 2024

What changes were proposed in this pull request?

Some proto2 ByteString.toByteArray() calls can be removed in order to avoid buffer copying.

What is the link to the Apache JIRA

HDDS-10480

How was this patch tested?

By existing tests.

@szetszwo szetszwo requested a review from duongkame March 7, 2024 17:13

final SCMRatisResponseProto responseProto = SCMRatisResponseProto
.parseFrom(response);
final SCMRatisResponseProto responseProto = SCMRatisResponseProto.parseFrom(response.toByteArray());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use the below to avoid creating new buffer too.

final SCMRatisResponseProto responseProto = SCMRatisResponseProto.parseFrom(response.newInput());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@duongkame , thanks for reviewing this!

The method parseFrom(InputStream) will call new CodedInputStream(InputStream), which creates a byte[] in the CodedInputStream constructor. Since it is InputStream, it probably will copy at least two times.

@szetszwo szetszwo requested a review from duongkame March 8, 2024 00:34
Copy link
Contributor

@duongkame duongkame 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 patch @szetszwo . LGTM.

@szetszwo
Copy link
Contributor Author

szetszwo commented Mar 8, 2024

@duongkame , thanks a lot for reviewing this!

@szetszwo szetszwo merged commit d94aadc into apache:master Mar 8, 2024
xichen01 pushed a commit to xichen01/ozone that referenced this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants