[code-reflection] RFR: Explicit Arena passing to Tensor construction and Session execution [v2]
Adam Sotona
asotona at openjdk.org
Tue Mar 4 18:33:25 UTC 2025
On Tue, 4 Mar 2025 18:26:19 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> I think what saves us from crashes in the current code is the the fact that `sessionAddress` needs to be passed to the various onnx API calls. And, since `sessionAddress` points at the session arena, the `Linker` will not allow that arena to be closed until the downcall has finished running (this is part of the contract specified in tthe Linker API). Which probably avoids the worst cases.
>>
>> As long as the lifetimes of the results of `run` are completely independent from that of the session (in the sense that it is ok for such results to "outlive" the session), then it should be ok -- but I couldn't find any guidance in the onnx API docs. The risk is that some of those results holds off to some memory of the session, and when the session is released, the result will point to already freed memory -- but I don't know if this could happen.
>
> It can happen for tensors and their data. I found no better prevention than use individual auto arena for each tensor, which is obviously a performance anti pattern.
Is there a way to allocate an individually GCed memory segment without a cost of creating the whole auto arena (and similarly an individually freed MS without a new confined arena cost)?
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/337#discussion_r1979997987
More information about the babylon-dev
mailing list