-
Notifications
You must be signed in to change notification settings - Fork 1
Description
What
Avoid serializing ConfigOptions for every scalar UDF call.
Why
Currently we serialize the config options as key-value map:
datafusion-udf-wasm/wit/world.wit
Line 85 in 149ed38
| config-options: list<tuple<string, string>>, |
However on the host these options are passed as Arc<ConfigOptions> and ConfigOptions itself does NOT have interior mutability. It is likely that multiple calls to invoke_async_with_args will have the same config options attached and hence the whole stringify-parse roundtrip becomes an unnecessary overhead.
How
Please implement #28 first to gauge the impact of this change!
Instead of passing the config options as string map, we could use a WIT resource instead. Now we need to decide when to create and destroy that resource. On the host, we should keep a map "Arc address" -> Arc<ConfigOptions> & resource to cache that conversion. By keeping the Arc alive we make sure that the address is a true identity because it cannot be reused. We should probably limit the number of cached options in that map (I don't se why you would ever need more than one TBH).