Skip to content

Comments

feat(memory-tracking): expose API to NullBuffer, ArrayData, and Array#8918

Open
notfilippo wants to merge 2 commits intoapache:mainfrom
notfilippo:filippo.rossi/memory-tracking-expose-api
Open

feat(memory-tracking): expose API to NullBuffer, ArrayData, and Array#8918
notfilippo wants to merge 2 commits intoapache:mainfrom
notfilippo:filippo.rossi/memory-tracking-expose-api

Conversation

@notfilippo
Copy link
Member

Which issue does this PR close?

Part of #8137. Follow up of #7303. Replaces #8040.

Rationale for this change

#7303 implements the fundamental symbols for tracking memory. This patch exposes those APIs to a higher level Array and ArrayData.

What changes are included in this PR?

New claim API for NullBuffer, ArrayData, and Array. New pool feature-flag to arrow, arrow-array, and arrow-data.

Are these changes tested?

Added a doctest on the Array::claim method.

Are there any user-facing changes?

Added API and a new feature-flag for arrow, arrow-array, and arrow-data.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 24, 2025
@notfilippo

This comment was marked as outdated.

@notfilippo
Copy link
Member Author

cc @alamb since you reviewed the original PR. cc @waynexia / @Dandandan as the original authors.

@alamb
Copy link
Contributor

alamb commented Feb 13, 2026

Thanks @notfilippo -- I don't have time to drive this type of change now (low level memory allocation tracking) -- I am overwhelmed by trying to keep things going. Hopefully some of the other committers will have time to help

/// ```
#[cfg(feature = "pool")]
fn claim(&self, pool: &dyn arrow_buffer::MemoryPool) {
self.to_data().claim(pool)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling to_data allocates a new Vec to create the ArrayData (the child buffers specifically)

Should we perhaps instead thread the claim API through the actual arrays / buffers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Updating my PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here maybe I should add a comment stating that Array impl can provide a more optimised method. Wdyt?

@alamb
Copy link
Contributor

alamb commented Feb 24, 2026

Thanks @notfilippo -- I am sorry for the delay in reviewing -- I am bummed no one else had a chance yet.

This API also came up today with @cetra3 and @adriangb in the context of DataFusion

If we can avoid the call to to_data I think this PR will be good to go from my perspective

@cetra3
Copy link
Contributor

cetra3 commented Feb 24, 2026

I have another PR open which does similar things, and avoids the to_data: #9433

Edit: actually I lie about the to_data thing, it still does it. Maybe it needs a little more work to prevent creating a vec in this instance

New `claim` API for NullBuffer, ArrayData, and Array.
New `pool` feature-flag to arrow, arrow-array and arrow-data.

Part of apache#8137.
Replaces apache#8040.
@notfilippo notfilippo force-pushed the filippo.rossi/memory-tracking-expose-api branch from ab67828 to e73b4cb Compare February 25, 2026 10:53
@notfilippo
Copy link
Member Author

I rebased the PR and I'll try to look into implementing claim for the Array variants. Could this be a follow-up PR or should I include it here? cc @alamb

@notfilippo
Copy link
Member Author

Done!

@notfilippo notfilippo force-pushed the filippo.rossi/memory-tracking-expose-api branch from 43f2888 to 176e7c1 Compare February 25, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants