[code-reflection] RFR: ONNX FFM Runtime initial work [v3]

Adam Pocock duke at openjdk.org
Mon Feb 10 21:57:23 UTC 2025


On Mon, 10 Feb 2025 13:51:10 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> cr-examples/onnx/src/main/java/oracle/code/onnx/OnnxRuntime.java line 153:
>> 
>>> 151:     }
>>> 152: 
>>> 153:     public Environment createEnv(LoggingLevel logLevel, String logId) {
>> 
>> There's some lifetime here to deal with... createEnv has a releaseEnv method, which is not dealt with here. Perhaps it would be convenient to associate the returned env segment with an automatic arena (Arena::ofAuto) that will be kept alive as long as the Environment instance is reachable which is, I think, what you want.
>
> Yes, there are definitely many places for improvements. This is just a first shot to make it working ASAP.
> I expect many refactoring rounds.

`OrtEnv` must be instantiated at most once in the lifetime of a process, if you close it and recreate it then you get mysterious crashes. That's why the Java API has a singleton for it which registers a JVM shutdown hook to close it. That has other problems as the hook runs concurrently with daemon threads, but I couldn't figure out a way around it.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/311#discussion_r1949951800


More information about the babylon-dev mailing list