Skip to content
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

[do not review] chore: add WasmRegistry and WasmModule #3044

Merged
merged 5 commits into from
May 14, 2024
Merged

Conversation

kostasrim
Copy link
Contributor

No description provided.

@kostasrim kostasrim self-assigned this May 14, 2024
@kostasrim kostasrim requested a review from dranikpg May 14, 2024 06:52
// The following line is problematic, it causes a SEGFAULT when we switch fibers
// after the command gets executed

// auto error = wasmtime_module_new(engine_, (uint8_t*)wasm.data, wasm.size, &module);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we comment this out we crash when we switch fibers @dranikpg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we switch fibers if there are no preemption points? The mutex below? Let's make everything thread-local or use a spinlock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, I had also commented out the locks all together. I will play around and ping

dranikpg
dranikpg previously approved these changes May 14, 2024
Comment on lines 30 to 36
wasi_config_ = wasi_config_new();
CHECK(wasi_config_);
wasi_config_inherit_argv(wasi_config_);
wasi_config_inherit_env(wasi_config_);
wasi_config_inherit_stdin(wasi_config_);
wasi_config_inherit_stdout(wasi_config_);
wasi_config_inherit_stderr(wasi_config_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to start it without wasi? We don't need it, it should be a pure sandbox

Copy link
Contributor Author

@kostasrim kostasrim May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasi is the portable abstraction of a system interface (for example reading from a socket read). Some of these are implemented while others have limited functionality. Either way, I think it's fine to have those?

// The following line is problematic, it causes a SEGFAULT when we switch fibers
// after the command gets executed

// auto error = wasmtime_module_new(engine_, (uint8_t*)wasm.data, wasm.size, &module);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we switch fibers if there are no preemption points? The mutex below? Let's make everything thread-local or use a spinlock

Comment on lines +61 to +65
// Very light-weight. Each Module is compiled *once* but each UDF call, e,g, `CALLWASM`
// will spawn its own instantiation of the wasm module. This is fine, because the former
// is the expensive operation while the later is used as the context upon the function
// will execute (effectively allowing concurrent calls to the same wasm module)
class WasmModuleInstance {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better leave a comment what the difference between engine/store/module are 🙂

@@ -0,0 +1,3268 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dranikpg taken as is

wasmtime::Store store_;
static wasmtime::Config GetConfig() {
wasmtime::Config config;
config.epoch_interruption(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have the same issue after we switch fiber we crash. But loading and executing wasm works fine, so for example when I merge the code in WasmFamily::Load with WasmFamily::Call it properly loads and executes the wasm binary. However it still crashes after it exits just like when we split this in two steps as described above.

}
std::unique_lock<util::fb2::SharedMutex> lock(mu_);
modules_.emplace(name, std::move(result.ok()));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will move registering modules here with a static flag that contains the paths

Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge, I'll steal your branch :neckbeard:

@kostasrim kostasrim changed the base branch from main to wasm May 14, 2024 17:01
@kostasrim kostasrim merged commit 1351e54 into wasm May 14, 2024
5 of 10 checks passed
@kostasrim kostasrim deleted the wasm_registry branch May 14, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants