-
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
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).
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ArrayByteBufferPool.java
Show resolved
Hide resolved
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
…tty-12.1.x/rehabilitate-quadratic-pool
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.
I'm not sure about Predefined
as it is.
The base class only calls the function bucketIndexFor
, so when predefined is asked for a large buffer that has no bucket, it won't call the other function, and just return whatever was asked, unpooled.
Considering this should simplify the functions.
I don't mind the idea of a Default
where the sizes are [1K, 2K, 4K, 8K, 16K, 17K, 32K, 64K]
.
IIRC, we tried the idea of a "learning" one in the past, but it was very difficult to figure out the capacities, and required a lot of extra code to figure them out.
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
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]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
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.
It is really good that we now have these alternative options to tune the byte buffer pool algorithm. However, what we don't have is metrics/stats collected in the normal pool that will easily allow us to come up with a configuration of these pools.
Specifically we have bucket.recordAcquire()
, when we really need bucket.recordAcquire(size)
, so we can record statistics on what the actual requested size is. Otherwise we might know that we have lots of 32KB buffers, but we won't know that only 17KBs were requested.
So I think this PR needs to improve the statistics collected and to make them available in the dump, so that a dump on shutdown can provide the information needed to pick and configure the right optimized pool
@gregw the default pool has 4K increments in buffer sizes, so it is already granular enough. I don't think The stats will depend so much on HTTP protocol version, WebSocket, TLS, QUIC, etc. that probably what's good in one case is not for another. My point being that we don't really want |
@sbordet it is precisely because buffer usage will vary greatly that recording detailed stats from a live system is necessary to well optimize the buffers. I don't think many users will be prepared to do experiments with 1K buffers in production systems. 4K is not good enough granularity as there may be 1K and/or 2K buffers requested. Adding the size to the signature doesn't mean that the stats always have to be kept, it just means that we can have an option to keep them. If they prove to be expensive, that option can be turned off. This should be a stats on all impls, so that if predefined buffer sizes are wrong, then we know. It could be as simple as counting how often a size is more that X% of the capcity. I don't think that is a huge expense. |
Signed-off-by: Ludovic Orban <[email protected]>
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.
thanks
As discussed with @sbordet,
ArrayByteBufferPool.Quadratic
could be useful in certain scenarios so we should un-deprecate it and fix its minor issues.