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

[MINOR] fix(client): Fix allocate size by add 9 bytes #1940

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maobaolong
Copy link
Member

What changes were proposed in this pull request?

Improve the preAllocated buffer size.

Why are the changes needed?

(Please clarify why the changes are needed. For instance,

  1. If you propose a new API, clarify the use case for a new API.
  2. If you fix a bug, describe the bug.)

Without this change, this encoded length always less 9 byte than byteBuf#readableSize after encoded.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

No need.

Copy link

github-actions bot commented Jul 22, 2024

Test Results

 2 791 files   - 1   2 791 suites   - 1   5h 50m 7s ⏱️ - 1m 35s
   988 tests ±0     986 ✅ ±0   1 💤 ±0  0 ❌  - 1  1 🔥 +1 
12 402 runs   - 1  12 385 ✅  - 2  15 💤 ±0  0 ❌  - 1  2 🔥 +2 

For more details on these errors, see this check.

Results for commit fa8fc8f. ± Comparison against base commit 9fd8ae0.

♻️ This comment has been updated with latest results.

@jerqi jerqi requested a review from leixm July 22, 2024 02:02
// headerEncodedLength = messageEncodedLength + messageTypeEncodedLength + bodyLength +
// messageEncodedLength
// {@link org.apache.uniffle.common.netty.MessageEncoder#encode}
int headerEncodedLength =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a static variable to represent the 9 bytes of the header.

@leixm
Copy link
Contributor

leixm commented Jul 22, 2024

Sine #1534 , allocateSize is a relatively large value, about twice the actual size. @rickyma Can you help check?

@rickyma
Copy link
Contributor

rickyma commented Jul 22, 2024

You need to be more careful when refactoring this, or else Uniffle Server might encounter OOM issues under high concurrency.

about twice the actual size

I think this is OK. Because the preAllocatedSize will be released very soon.

@maobaolong
Copy link
Member Author

@rickyma @leixm After thinking twice, I keep the original logic that let allocateSize calculate size twice as before. I just add the 9 byte into allocateSize by this PR, this small step will be safe.

@maobaolong maobaolong requested a review from leixm July 23, 2024 02:05
public int getSize() {
return length + 3 * 8 + 2 * 4;
// FIXME(maobaolong): The size is calculated based on the Protobuf message ShuffleBlock.
// If Netty's custom serialization is used, the calculation logic here needs to be modified.
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean netty still use the protobuf de/serialization?

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, Netty need only data size is enough, but for now server release usedmemory contains the block encoded size

Copy link
Member

Choose a reason for hiding this comment

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

In fact, Netty need only data size is enough

If so, why not removing the unused placeholder bits directly? Just for unified logic for grpc and netty?

zuston
zuston previously approved these changes Aug 19, 2024
Copy link
Member

@zuston zuston left a comment

Choose a reason for hiding this comment

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

+1 for this after reviewing this netty based network protocol. Although I think we should bind the unique requireBufferId with the required buffer size that is determinzed by the client side, that means we could release the allocated size more precise in the next accepting data in the server side logic

@zuston
Copy link
Member

zuston commented Aug 19, 2024

Please fix the conflict. After that, I think I can merge this assp. @maobaolong

@maobaolong
Copy link
Member Author

@zuston Conflicts has been resolved, but after review this PR, I found it hard to keep consistent with previous version, and the client and the server should be updated together.

@maobaolong maobaolong marked this pull request as draft August 28, 2024 05:19
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.

4 participants