Repository navigation
Fixes #12706 - Export ArrayByteBufferPool statistics via JMX. - #12709
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 <simone.bordet@gmail.com>
lorban
left a comment
There was a problem hiding this comment.
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.
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.
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.
Without the list, you can replace entries.size() with getPool().size() which is as cheap.
There was a problem hiding this comment.
But not consistent.
There was a problem hiding this comment.
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.
can we filter out buckets that don't have allocations at all?
There was a problem hiding this comment.
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 <simone.bordet@gmail.com>
The pools should have different Use |
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
|
@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 |
* Exposed bucket statistics as a list of maps. * Exposed non-bucket statistic map. * Fixed get[Direct|Heap]Memory() and exposed getAvailable[Direct|Heap]Memory(). * Updated JMX context attribute for Server in ServerMBean. This allow to distinguish ByteBufferPools, Schedulers, etc. among multiple servers and from HttpClient or other components. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
