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

Rehabilitate quadratic pool #12711

Open
wants to merge 5 commits into
base: jetty-12.1.x
Choose a base branch
from

Conversation

lorban
Copy link
Contributor

@lorban lorban commented Jan 14, 2025

As discussed with @sbordet, ArrayByteBufferPool.Quadratic could be useful in certain scenarios so we should un-deprecate it and fix its minor issues.

@lorban lorban requested review from gregw and sbordet January 14, 2025 10:58
@lorban lorban self-assigned this Jan 14, 2025
@lorban lorban force-pushed the experiment/jetty-12.1.x/rehabilitate-quadratic-pool branch from c62eede to 7769a33 Compare January 14, 2025 11:01
@lorban lorban force-pushed the experiment/jetty-12.1.x/rehabilitate-quadratic-pool branch from 7769a33 to c1c1153 Compare January 14, 2025 11:02
@lorban lorban marked this pull request as ready for review January 15, 2025 09:27
Signed-off-by: Ludovic Orban <[email protected]>
@lorban lorban requested a review from sbordet January 23, 2025 17:43
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

Other than renaming, this looks good.

However, see my thought bubble for how to make quadratic pool play nice with TLS (probably a different PR).

@@ -723,15 +724,12 @@ protected void acquire()
* A variant of the {@link ArrayByteBufferPool} that
* uses buckets of buffers that increase in size by a power of
* 2 (e.g. 1k, 2k, 4k, 8k, etc.).
* @deprecated Usage of {@code Quadratic} is often wasteful of additional space and can increase contention on
Copy link
Contributor

Choose a reason for hiding this comment

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

Interestingly enough, we have seen a few small contents being put into 4K buffers with the current buffer pool, so this pool may be more space efficient for those contents, as it can return a 1K buffer.

The main issue is for TLS, which needs an approx 17KB buffer, so it will get a 32KB one.

I wonder if it would be worthwhile to create a pool that wraps another pool and provides just a single specific sized buffer. So we could have a pool specialized for TLS buffers wrapping a quadratic pool? Best of both worlds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the default case, we are the only users of the buffer pool and we know upfront all the sizes we're going to use.

So I wonder if we shouldn't simply have a buffer pool that works with an arbitrary list of sizes that we would hardcode to the ones we need, i.e.: 1K, 4K, 8K, 17K and 64K?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be easy to implement. Give it a go.
Or how about a dynamic one, that learns the sizes it needs to allocate?

Signed-off-by: Ludovic Orban <[email protected]>
@lorban lorban requested a review from sbordet January 24, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

3 participants