[improve][fn] support WASM functions which can support many languages#21975
[improve][fn] support WASM functions which can support many languages#21975loongs-zhang wants to merge 1 commit intoapache:masterfrom
Conversation
|
This is a new feature for the Pulsar Function. Please create a PIP for this or start a discussion on the dev mailing list first. You could refer to here for how to submit a PIP. |
|
see #21992 for doc |
|
Just for info, a pure wasm java runtime is now in development https://github.com/dylibso/chicory I did use it successfully in some POC: |
It looks very good, what about the performance ? |
|
At this stage I haven't run any performance measurement as both the runtime and the integrations are at at very early stage. |
|
Personally, I prefer wasmtime-java, there's also no need to write native for bridge, and the low-level wasmtime is mature enough. |
|
I think the biggest advantage of chicory over wasmtime-java + wasmtime is the fact that the first is a pure meant to be a pure java implementation so it does not require to have any jni/ffi binding but yeah, in therm of maturity at this stage wasmtime is quite more mature. For example purpose, I'll try to write a small POC for chicory + pulsar to see how it would looks like |
|
Welcome, the cross platform capability of chicory is very good due to java, as for the wasmtime-java, it's only support linux-x86_64, windows-x86_64, macos-x86_64 and macos-aarch64. But now, almost all of servers are x86_64, so I overlooked this. @lburgazzoli You just need to pay attention to the code of |
|
Here a very simple POC: https://github.com/lburgazzoli/pulsar-function-wasm NOTES:
|
|
I would like to provide an SPI where submodules can be implemented using wasmtime-java and chicory respectively :) About pulsar-function-wasm-sdk, do we need implement similar SDKs for other languages? Of course, except for the existing SDK in pulsar functions. Then when a language is not supported by pulsar functions, we can quickly provide a lightweight implementation of pulsar functions sdk. When there is more time, we can continue to support the complete SDK. I think this is a good idea, do you have any other suggestions? @lburgazzoli |
I'm not sure hot that would really be feasible given the low level APIs the various runtime expose, but if you come up with something I can definitively try it out and help with the chicory implementation.
Given the current state of Wasm, an SDK is likely very needed otherwise each function would be required to re-implement the ABI. |
|
I will start abstracting SPI interfaces as soon as possible after the Chinese New Year. |
Motivation
The wasm bytecode is designed to be encoded in a size- and load-time-efficient binary format. WebAssembly aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.
This PR support run WASM functions
Verifying this change
see
pulsar-functions/java-examples/src/main/rust-function/README.mdandorg.apache.pulsar.functions.api.examples.WasmFunction(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: