Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved Middleware API #5228

Open
anlumo opened this issue Nov 7, 2024 · 1 comment
Open

Improved Middleware API #5228

anlumo opened this issue Nov 7, 2024 · 1 comment
Assignees
Labels
🎉 enhancement New feature! 📦 lib-middlewares About wasmer-middlewares 🕵️ needs investigation The issue/PR needs further investigation

Comments

@anlumo
Copy link

anlumo commented Nov 7, 2024

Motivation

Currently, the middleware API supplies two hooks:

  • per-module initialization
  • per-function initialization

Middlewares are also attached to engines (rather than modules or instances).

However, there is no connection between those two. This means that when a middleware encounters a new function, it does not know which module this function belongs to. Since parallel compilation is possible, it's also not possible to assume that the last module initialization belongs to the current function initialization (I guess).

The only middleware currently available is the metering example. In order to cope with this API, the middleware is restricted to handle a single module per engine via runtime check (with a panic).

Proposed solution

Either attach middlewares to modules or instances rather than the whole engine, or supply the module id to the per-function initialization.

Additional context

It would be good to have other middleware examples in order to demonstrate the additional possibilities of this API. Right now this seems only to be good for metering, but maybe I'm missing something.

@anlumo anlumo added the 🎉 enhancement New feature! label Nov 7, 2024
@xdoardo
Copy link
Contributor

xdoardo commented Nov 14, 2024

Hello, thanks for the proposal. The issue is this: middlewares can change the compilation of a module, and engines take care of doing said compilation, therefore they're inevitably tied. However, I think there's a way to get around that, so we'll get around to do this when we can allocate time for it.

@xdoardo xdoardo self-assigned this Nov 14, 2024
@xdoardo xdoardo added 🕵️ needs investigation The issue/PR needs further investigation 📦 lib-middlewares About wasmer-middlewares labels Nov 14, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🎉 enhancement New feature! 📦 lib-middlewares About wasmer-middlewares 🕵️ needs investigation The issue/PR needs further investigation
Projects
None yet
Development

No branches or pull requests

2 participants