-
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
Fixes #12706 - Export ArrayByteBufferPool statistics via JMX. #12709
base: jetty-12.0.x
Are you sure you want to change the base?
Conversation
sbordet
commented
Jan 14, 2025
- Exposed bucket statistics as a list of maps.
- Exposed non-bucket statistic map.
- Fixed get[Direct|Heap]Memory() and exposed getAvailable[Direct|Heap]Memory().
* Exposed bucket statistics as a list of maps. * Exposed non-bucket statistic map. * Fixed get[Direct|Heap]Memory() and exposed getAvailable[Direct|Heap]Memory(). Signed-off-by: Simone Bordet <[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.
There's a minor perf issue in toString
, otherwise LGTM.
private Statistics getStatistics() | ||
{ | ||
List<Pool.Entry<RetainableByteBuffer>> entries = getPool().stream().toList(); | ||
int inUse = (int)entries.stream().filter(Pool.Entry::isInUse).count(); |
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.
Converting to a list is needlessly wasteful, you could directly stream the pool here with:
int inUse = (int)getPool().stream().filter(Pool.Entry::isInUse).count();
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.
No, I need both the in-use count and the total count, and I would like them to be consistent, that's why I copy the pool to a list.
long pooled = _pooled.longValue(); | ||
long acquires = _acquires.longValue(); | ||
float hitRatio = acquires == 0 ? Float.NaN : pooled * 100F / acquires; | ||
return new Statistics(getCapacity(), inUse, entries.size(), pooled, acquires, _releases.longValue(), |
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.
Without the list, you can replace entries.size()
with getPool().size()
which is as cheap.
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.
But not consistent.
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.
None of those numbers are strictly consistent with each other at any point in time. Having an extra pair of slightly inconsistent numbers won't change anything in practice. Embrace the race.
private List<Map<String, Object>> getBucketsStatistics(boolean direct) | ||
{ | ||
RetainedBucket[] buckets = direct ? _direct : _indirect; | ||
return Arrays.stream(buckets).map(b -> b.getStatistics().toMap()).toList(); |
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.
can we filter out buckets that don't have allocations at all?
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.
That looks like something better left to the caller of this method as we do want to report the buckets that did no allocation.
btw. how can I export statistics for two distinct ArrayByteBufferPools - one used in the client and one in the server? It seems that I'm always getting a single pool exported. |
This allow to distinguish ByteBufferPools, Schedulers, etc. among multiple servers and from HttpClient or other components. Signed-off-by: Simone Bordet <[email protected]>
The pools should have different Use |
Signed-off-by: Simone Bordet <[email protected]>
@sbordet how these object pools are getting name assigned? I can't find that. I'm always seeing a single buffer pool in the mbean browser: |
It is possible that you are not registering the See: https://jetty.org/docs/jetty/12/programming-guide/arch/jmx.html#enabling-jmx-support |