Fix direct_memory_bytes in Flight stats to report actual direct buffer usage#21769
Fix direct_memory_bytes in Flight stats to report actual direct buffer usage#21769bowenlan-amzn wants to merge 3 commits into
Conversation
The previous implementation used MemoryMXBean.getNonHeapMemoryUsage() which reports metaspace + code cache + compressed class space -- not actual direct ByteBuffer allocations. The fallback (heap usage) was also incorrect. Replace with BufferPoolMXBean filtered on the 'direct' pool, which reports actual JVM direct buffer memory managed by ByteBuffer.allocateDirect(). Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
PR Reviewer Guide 🔍(Review updated until commit 8977126)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 8977126 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 9fd628c
Suggestions up to commit 8bec5e7
|
|
❌ Gradle check result for 8bec5e7: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit 9fd628c |
|
❌ Gradle check result for 9fd628c: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit 8977126 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21769 +/- ##
==========================================
Coverage 73.44% 73.45%
+ Complexity 75084 75063 -21
==========================================
Files 6016 6016
Lines 341072 341075 +3
Branches 49091 49093 +2
==========================================
+ Hits 250513 250526 +13
+ Misses 70641 70528 -113
- Partials 19918 20021 +103 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
The
direct_memory_bytesfield in/_flight/statscurrently reports JVM non-heap memory (MemoryMXBean.getNonHeapMemoryUsage().getUsed()) which includes metaspace, code cache, and compressed class space — not actual direct ByteBuffer allocations.The fallback path (
Runtime.totalMemory() - freeMemory()) reports heap usage, which is also incorrect.This PR replaces it with
BufferPoolMXBeanfiltered on the"direct"pool, which correctly reports memory allocated viaByteBuffer.allocateDirect().Context
While analyzing Flight memory accounting, we found this stat is misleading for operators trying to understand actual direct memory pressure from gRPC/Netty framing. The Arrow allocator stats (
arrow_allocated_bytes) are correct — onlydirect_memory_byteswas wrong.Check List
--signoffBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.