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

Buffer reusal in the BufferingResponseListener #12687

Open
wendigo opened this issue Jan 9, 2025 · 3 comments · May be fixed by #12691
Open

Buffer reusal in the BufferingResponseListener #12687

wendigo opened this issue Jan 9, 2025 · 3 comments · May be fixed by #12691

Comments

@wendigo
Copy link

wendigo commented Jan 9, 2025

Jetty version(s)
12.x

Enhancement Description

Is it possible for the BufferingResponseListener to accept ByteBufferPool to reuse buffers instead of allocating them per request?

@sbordet
Copy link
Contributor

sbordet commented Jan 9, 2025

@wendigo definitely a good to have.

@wendigo wendigo linked a pull request Jan 9, 2025 that will close this issue
@sbordet
Copy link
Contributor

sbordet commented Jan 9, 2025

@wendigo this might be trickier than expected.

The default max size for BufferingResponseListener is 2 MiB.

The default max capacity for ArrayByteBufferPool is 64 KiB.

If the response content is within 64 KiB, then the ByteBuffer is pooled, otherwise the pool will just allocate it on-the-fly like BufferingResponseListener is doing right now.

So yes, there is a benefit for small content, but for larger content you need to size the ArrayByteBufferPool max capacity accordingly.

@wendigo
Copy link
Author

wendigo commented Jan 10, 2025

@sbordet that's why in the PR i've posted I've used NonPooled one to make it compatible with the current implementation. For the pooled usage, the consumer should be responsible for providing a pool that actually pools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants