-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial WebAssembly subsystem #12666
Initial WebAssembly subsystem #12666
Conversation
0689bae
to
673bdd0
Compare
673bdd0
to
1abf895
Compare
src/v/ssx/work_queue.h
Outdated
#include "seastarx.h" | ||
#include "ssx/future-util.h" | ||
#include "utils/mutex.h" | ||
|
||
#include <seastar/core/abort_source.hh> | ||
#include <seastar/core/future-util.hh> | ||
#include <seastar/core/future.hh> | ||
#include <seastar/core/shared_ptr.hh> | ||
#include <seastar/core/thread.hh> | ||
#include <seastar/util/noncopyable_function.hh> | ||
|
||
#include <exception> | ||
#include <type_traits> | ||
#include <utility> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: clean up includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks done.
src/v/model/transform.h
Outdated
// Each transform revision has a UUID, which is the key for the wasm_binary | ||
// topic and can be used to uniquely identify this revision. | ||
uuid_t uuid; | ||
// The offset of the commmitted WASM source in the wasm_binary topic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks fixed.
src/v/wasm/wasmedge.cc
Outdated
vlog( | ||
wasm_log.trace, | ||
"Transforming batch: {}", | ||
batch.header().record_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can log the whole header here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly 😄
std::vector<ss::sstring> args{_meta.name()}; | ||
absl::flat_hash_map<ss::sstring, ss::sstring> env = _meta.environment; | ||
env.emplace("REDPANDA_INPUT_TOPIC", _meta.input_topic.tp()); | ||
env.emplace("REDPANDA_OUTPUT_TOPIC", _meta.output_topics.begin()->tp()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do i understand that correctly that for now we support only one output topic ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Added a comment here.
src/v/wasm/wasmedge.cc
Outdated
args, env, _logger); | ||
register_wasi_module(wasi_module.get(), wasmedge_wasi_module); | ||
|
||
(void)_worker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line seems like not needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks removed, we'll add compilation on an alien thread to later.
// Per transform probe | ||
class transform_probe { | ||
public: | ||
using hist_t = log_hist_public; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this histogram light enough to be used per transform ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(log_hist_public) == 160
so I think so? If we have 1000 different transforms on a shard for 1000 partitions then we get 160kB which feels small enough. Happy to just switch this to a counter and have a stat for CPU utilization instead?
@@ -324,3 +324,18 @@ ExternalProject_Add(protobuf | |||
-Dprotobuf_BUILD_TESTS=OFF | |||
${common_cmake_args} | |||
) | |||
|
|||
ExternalProject_Add(WasmEdge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an entry to: https://github.com/redpanda-data/redpanda/blob/dev/licenses/third_party.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 done - also removed v8
1abf895
to
1bdd788
Compare
1bdd788
to
a910092
Compare
4460b5b
to
059366b
Compare
Force push: Added named constants to redpanda Wasm module error numbers |
great idea, and follow is reasonable |
This will be used in the Wasm engine integration and is a useful abstraction for fibers to interact with a running seastar thread. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Right now util depends on json, so this prevents models from depending on util Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
d3d4f61
to
c9d1d7b
Compare
Force push: Added tests for FFI helpers, removed shared library cycle with json -> model -> utils. |
c9d1d7b
to
6c0c317
Compare
This commit defines a ABI for wasm modules to perform transforms within redpanda. There are also helpers for custom host bindings that are defined in an engine agnostic way. See redpanda-data#12322 for the corresponding guest side bindings as well as a video overview of the ABI contract. Additionally, a WASI module is defined, which supports a subset of the WASI standard. Namely, environment variables and writing to std{out,err} is supported. There are currently bindings to both WasmEdge and wasmtime, although the wasmtime integration is mostly experimental and can easily crash the redpanda process (see scylladb/scylladb#14163). Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
tinygo doesn't yet use wasm/wasi1p build tags like upstream go, so just switch to using tinygo completely as the build tag. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Now that we're building assets as part of CMake Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
6c0c317
to
e44376a
Compare
Force pushed to fix a test that changed after the seastar upgrade |
These functions where already defined in redpanda-data#12666 and their encoding. We also add a stub version of the ABI for IDEs that don't use the tinygo build tags (and we can build/test this package in standard go). Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
These functions where already defined in redpanda-data#12666 and their encoding. We also add a stub version of the ABI for IDEs that don't use the tinygo build tags (and we can build/test this package in standard go). Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
These functions where already defined in redpanda-data#12666 and their encoding. We also add a stub version of the ABI for IDEs that don't use the tinygo build tags (and we can build/test this package in standard go). Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Add the initial Wasm engine to Redpanda.
Right now we are using WasmEdge as the underlying engine but the engine that is used is abstracted away behind some interfaces so that we can easily extend it to other runtimes. I have a branch that shows this interface works fine for wasmtime as well.
Generally this component exists in isolation from the rest of the system, but this new subsystem will eventually be consumed by the transform subsystem.
Major pieces:
pandaproxy::schema_registry
subsystem for usage within our host moduleThe guest side of the ABI is implemented in #12322, and there is a video overview of how the ABI contract works here.
Wasm powered Data Transforms will be available in the community edition of Redpanda hence this code all being written under the BSL
NOTE:
Right now I am checking in theI hooked up the tests into the build system..wasm
test fixtures, but after #12322 goes in I will hook that into the build system and enable more tests.Backports Required
Release Notes