[code-reflection] RFR: Explicit Arena passing to Tensor construction and Session execution [v2]

Adam Sotona asotona at openjdk.org
Tue Mar 4 14:40:04 UTC 2025


On Tue, 4 Mar 2025 14:35:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> That is the intention. If we want to cache sessions and allow multiple executions, they must be constructed with a different arena than each of the execution. Execution has different lifecycle than the session.
>
> Ok -- since you have a situation of dependent lifetimes (e.g. you cannot afford the session arena to be closed _while_ the `run` method is executing), I'd suggest to _always_ create the session using an automatic arena. Then having a lifetime dependency becomes non-problematic, because the `Session` object you call `run` on will always keep the session address alive. But if we leave to users the choice of which arena to pick for the session, they could shoot themselves in the foot, by picking e.g. a shared arena and then closing it _while_ `run` is executing.

I don't see a problem here. Users can also close a stream while reading it.

-------------

PR Review Comment: https://git.openjdk.org/babylon/pull/337#discussion_r1979593310


More information about the babylon-dev mailing list