-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: jetty-12.1.x
Are you sure you want to change the base?
Rehabilitate quadratic pool #12711
Conversation
c62eede
to
7769a33
Compare
…stic for factor Signed-off-by: Ludovic Orban <[email protected]>
7769a33
to
c1c1153
Compare
…tty-12.1.x/rehabilitate-quadratic-pool
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ArrayByteBufferPool.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ArrayByteBufferPool.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ludovic Orban <[email protected]>
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ArrayByteBufferPool.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ludovic Orban <[email protected]>
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/MathUtils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]>
As discussed with @sbordet,
ArrayByteBufferPool.Quadratic
could be useful in certain scenarios so we should un-deprecate it and fix its minor issues.