Add native memory stat and task cancellation scaffolding - #21637
Conversation
himshikhagupta
left a comment
There was a problem hiding this comment.
Code changes look good. Can we just check the structuring once?
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 963e148.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
dd1c96a to
5bc0743
Compare
5bc0743 to
963e148
Compare
PR Reviewer Guide 🔍(Review updated until commit 4e4afe2)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 4e4afe2 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 4e4afe2
Suggestions up to commit 298b746
Suggestions up to commit 920793a
Suggestions up to commit e5fc074
Suggestions up to commit e5fc074
|
|
❌ Gradle check result for 963e148: 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 ce41123 |
|
❌ Gradle check result for ce41123: 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 cf117b6 |
|
❌ Gradle check result for cf117b6: 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? |
cf117b6 to
20c1442
Compare
|
Persistent review updated to latest commit 20c1442 |
|
❌ Gradle check result for 20c1442: 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 920793a |
Signed-off-by: Ajay Raj Nelapudi <ajnelapu@amazon.com>
920793a to
298b746
Compare
|
Persistent review updated to latest commit 298b746 |
Signed-off-by: Ajay Raj Nelapudi <ajnelapu@amazon.com>
|
Persistent review updated to latest commit 4e4afe2 |
|
Persistent review updated to latest commit 4e4afe2 |
The makeNodeStatsWithResourceUsage helper was missing the AnalyticsBackendNativeMemoryStats parameter added in opensearch-project#21637. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
* Fix StringViewArray buffer bloat: gc() before FFI export StringViewArray::slice() shares ALL backing buffers via Arc::clone. When DataFusion's hash aggregate emits output (EmitTo::All + slice into 8192-row batches), each slice carries the full backing buffer pool. For a 14M-group aggregate with SearchPhrase strings, this means 174MB per batch instead of 0.4MB — a 435x amplification. Add compact_string_view_columns() in stream_next() that calls gc() on Utf8View/BinaryView columns before C Data Interface export. This compacts each batch to contain only its own referenced strings. Validated on 4-shard ClickBench q19: Before: 9748 batches × 174MB = 1.7TB, 12 minutes After: 9748 batches × 0.4MB = 4GB, 11 seconds (65x faster) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Add Rust unit tests for compact_string_view_columns Regression guard for e2fd9bc (StringView buffer bloat fix). Tests prove that sliced StringView/BinaryView batches carry inflated backing buffers and that gc() compacts them to proportional size. Covers: large buffer compaction, inline-only no-op, empty array safety, BinaryView parity, and non-view passthrough. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Skip gc() on non-sliced batches; add bloat-detection tests compact_string_view_columns now checks whether backing buffers are over-allocated before calling gc(). Non-sliced batches (common case) pay only an O(n) view scan instead of a full buffer copy. New tests: - view_needs_gc_detects_bloat: proves detection correctly identifies sliced arrays vs non-sliced arrays - non_sliced_batch_skips_gc: proves non-sliced batches pass through without allocation/copy Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Add stream_next integration test; fix non_sliced skip proof - New integration test (stringview_gc_test.rs): feeds a sliced 10K→100 StringView batch through df_stream_next and asserts the output backing buffers are compact (<10KB, not ~300KB). Fails immediately if compact_string_view_columns is removed from stream_next — the actual regression guard for this fix. - Fix non_sliced_batch_skips_gc: use Arc::ptr_eq to prove the fast path returns the original column without copying, not just that sizes match. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * retrigger CI Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Fix DiskUsageTests compilation: add missing NodeStats arg The makeNodeStatsWithResourceUsage helper was missing the AnalyticsBackendNativeMemoryStats parameter added in #21637. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> --------- Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
…project#21637) * Add native memory stat and task cancellation scaffolding Signed-off-by: Ajay Raj Nelapudi <ajnelapu@amazon.com> Co-authored-by: Bukhtawar Khan <bukhtawa@amazon.com>
…ject#21753) * Fix StringViewArray buffer bloat: gc() before FFI export StringViewArray::slice() shares ALL backing buffers via Arc::clone. When DataFusion's hash aggregate emits output (EmitTo::All + slice into 8192-row batches), each slice carries the full backing buffer pool. For a 14M-group aggregate with SearchPhrase strings, this means 174MB per batch instead of 0.4MB — a 435x amplification. Add compact_string_view_columns() in stream_next() that calls gc() on Utf8View/BinaryView columns before C Data Interface export. This compacts each batch to contain only its own referenced strings. Validated on 4-shard ClickBench q19: Before: 9748 batches × 174MB = 1.7TB, 12 minutes After: 9748 batches × 0.4MB = 4GB, 11 seconds (65x faster) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Add Rust unit tests for compact_string_view_columns Regression guard for e2fd9bc (StringView buffer bloat fix). Tests prove that sliced StringView/BinaryView batches carry inflated backing buffers and that gc() compacts them to proportional size. Covers: large buffer compaction, inline-only no-op, empty array safety, BinaryView parity, and non-view passthrough. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Skip gc() on non-sliced batches; add bloat-detection tests compact_string_view_columns now checks whether backing buffers are over-allocated before calling gc(). Non-sliced batches (common case) pay only an O(n) view scan instead of a full buffer copy. New tests: - view_needs_gc_detects_bloat: proves detection correctly identifies sliced arrays vs non-sliced arrays - non_sliced_batch_skips_gc: proves non-sliced batches pass through without allocation/copy Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Add stream_next integration test; fix non_sliced skip proof - New integration test (stringview_gc_test.rs): feeds a sliced 10K→100 StringView batch through df_stream_next and asserts the output backing buffers are compact (<10KB, not ~300KB). Fails immediately if compact_string_view_columns is removed from stream_next — the actual regression guard for this fix. - Fix non_sliced_batch_skips_gc: use Arc::ptr_eq to prove the fast path returns the original column without copying, not just that sizes match. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * retrigger CI Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Fix DiskUsageTests compilation: add missing NodeStats arg The makeNodeStatsWithResourceUsage helper was missing the AnalyticsBackendNativeMemoryStats parameter added in opensearch-project#21637. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> --------- Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
Description
Add native memory stat and task cancellation scaffolding
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By 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.