-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-33743: [Java] Release outstanding buffers when BaseAllocator is being closed #33744
Conversation
|
ef6774c
to
8b99605
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose? I don't think we want this.
This silently suppresses an application logic error, and forces all allocations to go through a lock. The exception you get if there are unclosed buffers is very intentional.
The close() method's docstring is admittedly misleading, but I do not think the intent was to just close all buffers for you. (I think it's speaking more towards releasing any pooled or cached memory, which is definitely true for the Netty implementation.)
Manual reference counting of Arrow Java library can become very tricky, even becomes the bottle neck of daily development's efficiency in codes of complicated Java systems that relies on Arrow. This is just one way to make Arrow just be usable somehow in that case. Or a more complete solution I can come up with is to include:
I understand performance should be considered emphatically in Arrow, however it's true that we must rely on smarter Would you think this topic is worth discussion? I am indeed not hurry to get this patch merged until the best solution is shaped. Thanks. |
This patch forces everyone to take the opposite tradeoff, however. Some sort of nursery that auto-closes buffers may be useful, but I think it should be separate from the base allocator. (The allocator also has a 'listener' to be notified of allocation/deallocation events; possibly you could build this mechanism on top of that.) And nondeterministic collection of buffers is liable to bite you; the GC does not see into native allocations and you can run out of memory despite having 'free' memory because the GC has not collected the small Java-side objects that hold the large native buffers. |
Thanks and would you suggest to add a new implementation of interface
Yes I can image something like that too. What I can try is to reuse the JVM's direct memory counter which can trigger GC when reaching its limit, or rebuild a similar counter like that. Not sure if there are some better solutions but this one is probably OK since it was at least from JVM itself. |
I don't think it needs a new interface. |
I meant a new implementation of the interface, e.g.
|
Ah, ok. That sounds fine. I would explore the allocation listener further, though... |
I see. I'll find out to what extent can allocation listener be leveraged in this feature. Thanks for the suggestion. |
Closing because it has been untouched for a while, in case it's still relevant feel free to reopen and move it forward 👍 |
|
See apache/arrow-java#223
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?
No