You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DISSCUSSION] the memory tracking approach that better handles shared buffers #6439
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
See this comment #6363 (comment),
when the Buffer's data is shared between many Buffer, the capacity() method will always return the total buffer memory usage, which causes the issue #6363, we need discussion the better memory track for shared buffers.
This is changing what these methods report to something else that I'm not sure is correct. Whilst this formulation may benefit your use-case, there are common situations where it will now under report... Perhaps you might file a ticket to discuss a memory tracking approach that better handles shared buffers, as that is the actual issue here. This is not a bug
I personally prefer the allocator approach which gives the most accurate stats in theory. Given we in some aspects encourage sharing underlying buffer and arrays, only changing the behavior of .capacity() would still cause problems for end users when they want to track how many physical memories are used somewhere (e.g., in one query session).
I personally prefer the allocator approach which gives the most accurate stats in theory.
I agree with @waynexia -- if the usecase is "accurately track the total memory used across some number of Arrays which (potentially) share underlying Buffers", I think this needs a hook into the underlying allocator. There is proposed PR #6336 which might be worth a look (I haven't had a chance to really understand it yet myself)
I don't know if this is the right place to post this, but if this is being reworked, it would also be very useful to have a total memory usage method available within builders, especially for nested stuff. I'm writing a parser which outputs record batches at a static number of rows, but that doesn't work very well when the goal is to keep memory usage roughly constant. It would be nice to be able to get a roughly accurate measure of memory usage in builders in addition to arrays/buffers.
Builders are an interesting point, but come with two potential challenges to be aware of:
Builders tend to over-allocate to avoid repeatedly reallocating
Updating memory accounting per element is likely prohibitively expensive
This means any "eager" memory computation is likely to work poorly, however, the lazy approach as currently implemented for arrays could actually work quite well.
I could see a world where we remove lazy memory tracking for arrats in favour of eager allocation tracking, and add lazy memory tracking for builders
As this appears to have stalled slightly I have created a POC in #6590 for what I think eager memory tracking for arrays could look like.
I don't really have the capacity to drive this initiative, but I think the approach in the PR should be relatively straightforward for someone to pick up and run with.
Activity
tustvold commentedon Sep 23, 2024
#3960 is likely related.
Tagging @jhorstmann @waynexia @alamb
waynexia commentedon Sep 23, 2024
I personally prefer the allocator approach which gives the most accurate stats in theory. Given we in some aspects encourage sharing underlying buffer and arrays, only changing the behavior of
.capacity()would still cause problems for end users when they want to track how many physical memories are used somewhere (e.g., in one query session).alamb commentedon Sep 24, 2024
I agree with @waynexia -- if the usecase is "accurately track the total memory used across some number of Arrays which (potentially) share underlying
Buffers", I think this needs a hook into the underlying allocator. There is proposed PR #6336 which might be worth a look (I haven't had a chance to really understand it yet myself)kszlim commentedon Oct 19, 2024
I don't know if this is the right place to post this, but if this is being reworked, it would also be very useful to have a total memory usage method available within builders, especially for nested stuff. I'm writing a parser which outputs record batches at a static number of rows, but that doesn't work very well when the goal is to keep memory usage roughly constant. It would be nice to be able to get a roughly accurate measure of memory usage in builders in addition to arrays/buffers.
tustvold commentedon Oct 19, 2024
Builders are an interesting point, but come with two potential challenges to be aware of:
This means any "eager" memory computation is likely to work poorly, however, the lazy approach as currently implemented for arrays could actually work quite well.
I could see a world where we remove lazy memory tracking for arrats in favour of eager allocation tracking, and add lazy memory tracking for builders
kszlim commentedon Oct 19, 2024
That would be super useful for my use case
tustvold commentedon Oct 19, 2024
As this appears to have stalled slightly I have created a POC in #6590 for what I think eager memory tracking for arrays could look like.
I don't really have the capacity to drive this initiative, but I think the approach in the PR should be relatively straightforward for someone to pick up and run with.
alamb commentedon Aug 14, 2025
@waynexia has begun implementing memory tracking
I have filed an epic to track the work let's continue there
docs: Remove stale "temporary fix" note from `get_record_batch_memory…