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
Extensible RetainableByteBufferPool #6322 #6513
Extensible RetainableByteBufferPool #6322 #6513
Conversation
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…Buffer> for encrypted input Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…6322-UseRetainableByteBuffer
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban The intention is not to change the existing behaviour. I don't think I have and the CI failure appears to be exactly that.... a CI failure. Will redo the CI tests to see. But I'm a strong advocate of making this class extensible, even if we don't add the badly named |
Dumpable Signed-off-by: Greg Wilkins <gregw@webtide.com>
…f github.com:eclipse/jetty.project into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets Signed-off-by: Greg Wilkins <gregw@webtide.com>
Sampled Pool Signed-off-by: Greg Wilkins <gregw@webtide.com>
…yteBuffer' into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets
@sbordet @lorban ignoring the
|
maxBucketSize, | ||
maxHeapMemory, | ||
maxDirectMemory, | ||
TypeUtil::log2NextPowerOf2, |
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 against the power of 2 idea, but perhaps it should be stripped out to maintain, as you say, dumpability and statistics.
@sbordet The problem with stripping it out, is that we then have no way of actually testing that the class is really extensible. There were a lot of little assumptions in the code that depended on linear buckets. This PR fixes them, but if we took out LogBuckets, it would be easy for a change to revert to having such a assumptions. I could move LogBuckets to test??? But I really don't see any harm having it available, as it will allow us to test with it in real world deployments. |
jetty-io/src/main/java/org/eclipse/jetty/io/ArrayRetainableByteBufferPool.java
Outdated
Show resolved
Hide resolved
…yteBuffer' into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets Updates from review Signed-off-by: Greg Wilkins <gregw@webtide.com>
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 quite like the idea behind this change. More visibility and extensibility is always good to have. I just think that the buckets should be sampled instead of the pool.
{ | ||
private final RetainableByteBufferPool _pool; | ||
private final SampleStatistic _heap = new SampleStatistic(); | ||
private final SampleStatistic _direct = new SampleStatistic(); |
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 think those two counters are going to be a bit meaningless at the pool layer. IMHO it would be a lot more informative to move them to the Bucket
layer, maybe by creating a DumpableBucket
class.
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.
Hmmm good test for extensibility to have SampledBuckets. Will try....
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.
Actaully, thinking about it, we can just run with a small factor and then we will effectively get a histogram of the acquired sizes. So maybe this class is not needed after all.
jetty-io/src/main/java/org/eclipse/jetty/io/ArrayRetainableByteBufferPool.java
Outdated
Show resolved
Hide resolved
jetty-io/src/main/java/org/eclipse/jetty/io/ArrayRetainableByteBufferPool.java
Outdated
Show resolved
Hide resolved
if (maxCapacity <= 0) | ||
maxCapacity = 64 * 1024; | ||
if ((maxCapacity % _factor) != 0 || _factor >= maxCapacity) | ||
|
||
final int f = factor <= 0 ? 1024 : factor; |
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.
Drop final
, not necessary.
* uses buckets of buffers that increase in size by a power of | ||
* 2 (eg 1k, 2k, 4k, 8k, etc.). | ||
*/ | ||
public static class ExponentialPool extends ArrayRetainableByteBufferPool |
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.
Not sure we want to make this public
, as it binds us to maintain it, etc.
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 want to make it public so we can easily try using it in real deployments.
But as there appears to be resistance to this idea, I'll move to test and we can used the sampled one to gather data to see if ExponentialPool
is worthwhile or not.
* @see SampleStatistic | ||
*/ | ||
@ManagedObject | ||
class SampledPool implements RetainableByteBufferPool, Dumpable |
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.
This class is implicitly public
, which I don't think it's a good idea.
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.
We want at least this one to be public, so we can run real deployments and capture data about the pool usage. You can't simultaneously argue that ExponentialPool
is not justified by any data and then prevent anything that allows the data to be collected!
} | ||
|
||
@ManagedAttribute("Heap acquire samples") | ||
public SampleStatistic getHeapSample() |
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.
Unfortunately SampleStatistic
is not manageable, so this JMX exposure results in no data being exposed.
I think we need either more specific getters, or MXBean-ify SampleStatistic
which may not be easy.
I would make this class package private in ArrayRBBP
for now, and eventually open it up later.
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.
If it is private, then we can't use it to gather any info.
Anyway, I'm going to look at sampling on buckets rather than on acquire.
capacity = capacity * 2; | ||
} | ||
|
||
System.err.println(pool.dump()); |
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.
Remove this?
…yteBuffer' into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets Updates from review Signed-off-by: Greg Wilkins <gregw@webtide.com>
@lorban @sbordet I have removed I have moved the ExponentialPool to be an inner class of the test. So process from here is to release this.... ask some real clients do give us some server dumps; analyse the "histograms"; if an ExponentialPool looks like it will work, then re-release with that class public and test. |
…yteBuffer' into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets Updates from review Signed-off-by: Greg Wilkins <gregw@webtide.com>
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.
Besides the checkstyle failure, LGTM.
} | ||
} | ||
|
||
return String.format("%s{capacity=%d,inuse=%d(%d%%),used=%d%%}", |
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 the used
calculation will report anything meaningful, a more useful metric would be to calculate the mean 'waste' (i.e.: the difference between the requested size and the returned buffer's capacity) but that would require some extra processing.
I think we should leave this as-is and eventually revisit that later 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.
Agreed. We are kind of thwarted by the fact that we have no idea if a buffer is in fill or flush mode.
At least with this metric, it is sampling buffers that have a pointer between 0 and capacity, which is at least a hint of partial usage.
…yteBuffer' into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets fix checkstyle Signed-off-by: Greg Wilkins <gregw@webtide.com>
…yteBuffer' into jetty-10.0.x-6322-UseRetainableByteBuffer-LogBuckets fix checkstyle removed useless metric Signed-off-by: Greg Wilkins <gregw@webtide.com>
@sbordet nudge!!! |
Closed in favour of #6538 |
Improves on #6332 for #6322
Add a Log2 bucket size imple for ArrayRetainableByteBufferPool
Even if we don't actually add/use the
LogBucket
class, I think the changes made to make the ArrayRetainableByteBufferPool extensible are good ones to have.Signed-off-by: Greg Wilkins gregw@webtide.com