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

netty: The optimization of applying for a minimum of 4096 off-heap memory per request has no effect in non-unaryRequest mode #11719

Open
jammyMarse opened this issue Nov 29, 2024 · 1 comment

Comments

@jammyMarse
Copy link

ClientCallImpl:
image
MessageFramer:
image
image
image
NettyWritableBufferAllocator:
image

In non-unaryRequest mode, 4096 bytes of off-heap memory will be re-applied for each message
If you send small packet requests frequently (for example, 100 bytes each time), a lot of external memory will be wasted, and this 4096 optimization logic will not take effect.

@ejona86 ejona86 added this to the Next milestone Dec 3, 2024
@ejona86
Copy link
Member

ejona86 commented Dec 3, 2024

Yeah, it does seem we would keep allocating the 4k and then only using a small part. commitToSink() will clear the buffer and it won't be used across messages.

Are you sending many small messages at once, where we could batch them? Or are you needing to send each of the small messages immediately, without waiting for further small messages?

We could remove the MIN_BUFFER part. I'd have to look further if there are any implications there. For many messages sent back-to-back, it'd be good to provide a corking API (which would avoid calling flush() after each message), so that they could be encoded into a single buffer.

@ejona86 ejona86 added the netty label Jan 9, 2025
@ejona86 ejona86 changed the title The optimization of applying for a minimum of 4096 off-heap memory per request has no effect in non-unaryRequest mode netty: The optimization of applying for a minimum of 4096 off-heap memory per request has no effect in non-unaryRequest mode Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants