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

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Mar 4 14:40:04 UTC 2025


On Tue, 4 Mar 2025 14:06:22 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> (I see that this is done to cache the session --- but IMHO this feels like the caching tail is wagging the API dog a bit).
>
> 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.

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

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


More information about the babylon-dev mailing list