Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-22 Thread Jacques Nadeau
Hongze, I don't realistically have time to iterate with you on this. I agree that there could be easier apis to support leak detection. That being said, just because things could be refactored to make something easier isn't always a good enough reason to refactor them. I wonder if you can do the fi

Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-12 Thread Hongze Zhang
Thanks for sharing the information Laurent. I'd think JDK will always provide options to leverage garbage collector when it comes to cleaning up external resources (like native memory) binding to a object. In panama, as you can see, the new MemorySegment interfaces still allow users to register

Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-12 Thread Hongze Zhang
Hi Micah, Please see my another reply. Do you think making the whole approach as "leak detector/handler" will help reducing the complexity of these semantics? We can also remove the mode that disables manual-release. So when the delector is enabled, that only unclosed buffers will be handled by

Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-12 Thread Hongze Zhang
Hi Jacques, Thanks for sharing the detailed thoughts on this. Let me try addressing them as following, with probably re-prioritized order: > Clearly this patch was driven by an implicit set of needs but it's hard to > guess at what they are. The issue the patch tries to solve is pretty simple:

Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-07 Thread Laurent Goujon
Worth also observing that the Java community has been recognizant of the issues with the current approach around direct byte buffer and GC, and has come up with a proposal/implementation to avoid interaction with GC and give more direct control. The proposal (actually, its 3rd iteration) is describ

Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-07 Thread Jacques Nadeau
Clearly this patch was driven by an implicit set of needs but it's hard to guess at what they are. As Laurent asked, what is the main goal here? There may be many ways to solve this goal. Some thoughts in general: - The allocator is a finely tuned piece of multithreaded machinery that is used on h

Re: Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-07 Thread Micah Kornfield
In addition to the points raised by Laurent, I'm concerned about having two possible idioms in the same library. It means code written against the library becomes less portable (you need to know how the memory allocator is using GC or not). I understand manual memory management in Java is tedious

Re:Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-07 Thread Hongze Zhang
We don't have to concern about that since no difference will be made on current manual release path unless "MemoryChunkCleaner" is explicitly specified when creating BufferAllocators. Manual ref counting will be only discard/ignored in "MemoryChunkCleaner", while by default "MemoryChunkManager"

Re: Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-06 Thread Laurent Goujon
Unless I missed something in the big picture, but it seems that using a GC based approach would make things much inefficient in terms of memory management and would cause probably quite the confusion for all the systems out there which rely on refcounting for keeping things in check, I'm not sure w

Re:Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-05 Thread Hongze Zhang
Hi Laurent, Sorry I might describe it unclearly and yes, the purpose is straightforward: to discard (in another strategy rather than default) the usage of Java buffer ref counting and rely on GC to do cleanup for the buffers. Though some design changes to Allocator APIs maybe required to ach

Re: [DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-10-04 Thread Laurent Goujon
Hi, I gave a quick look at your patches but to be honest, it's not easy to figure out the problem you're trying to solve in the first place. Or is it simply to discard the use of ref counting to track buffer usages and relying on Java references to keep track of buffers at the expense of creating

[DISCUSS][Java] Adding GC-Based reference management strategy for buffers

2021-09-29 Thread Hongze Zhang
Hi, I would like to discuss on the potential of introducing a GC-based reference management strategy to Arrow Java, and we have already been working on an implementation in our own project. I have put the related codes in following branch and if it makes sense to upstream Apache Arrow I can open