Can we cache loaded MOJO models in memory to avoid duplication if `H2OMOJOPipelineModel` transformer is instantiated multiple times?
Actions:
1) verify how many times the transformer is instantiated if there is n-partitions on an executor
2) introduce a local cache (WeakReference) of for loaded MOJO models
CC:
#94138 (https://support.h2o.ai/a/tickets/94138) - Re: Deploying MOJO on Spark
We have this code, but after testing it today I can verify it does not work as expected. the reader back end is created every time the prediction is done. Will fix, for start
If we put print statement into getOrCreateModel we see it is being created all over again.
First step is to create some sort of registry which is local to executor and ensures the mojo bytes does not have to be serialized and deserialized and new instance created
Created first implementation which avoids serializing the mojo and creating new instance for each row.
We should however investigate why this was happening in the first place. Putting this change to release so the user can try it as soon as possible