Skip to content

Implement a plugin system #106

Closed
Closed

Description

@caelunshun

This is a key component in making Feather usable.

Requirements:

  • Implement a system which dynamically loads plugins at runtime. Plugins should be able to handle events and register Systems.
  • Plugins should be able to access and modify components.
  • The boundary between plugins and server should be efficient, ideally zero-cost.
  • Plugins should be written in Rust.

The proposal is to compile plugins to WebAssembly and run them using wasmer. At server startup, plugins will be loaded and an init function will be called. Here, plugins will be able to register systems and event handlers with the host.

Any systems registered by a plugin will be added to the DispatcherBuilder at init time. This means that plugin systems will run in the same way normal ones do.

Plugins will be required to specify the system data they require for each system, much like systems on the host, but components and resources will be represented in a more abstract way. For example, they will not have to manually write events; rather, this will be handled transparently on the host.

Any requests and updates of data by a plugin will require a host call. The host exposes functions to query and update data. On the host side, any SystemData required by the plugin will be stored in wasmer::Ctx, and inside a host function, the function will take the SystemData from the Ctx and use it as necessary. The exact details in how this will be implemented will be investigated later, but we know it is possible.

The plugin API itself will look much like the Bukkit API at first glance, with the main difference being the requirement for specifying what data an event handler requires. In addition, plugins will be allowed to have a state struct which is also passed to any event handler or system. Using this, it can access any necessary global state. The state struct will be required to be Send + Sync, since in the future, plugins may be invoked in parallel (although currently, this is not possible since wasmer::Instance does not implement Sync).

Several types from feather-core will have to be moved to the plugin API, such as Position. Also, feather-blocks and feather-items will be exposed to plugins.

The current plan is to first implement a proof of concept using Specs with Wasmer before proceeding to write the actual plugin system. Work on this should begin within the next few months.

Activity

  1. aramperes commented on Sep 2, 2019

    @aramperes
    Contributor

    Something to consider is the design of the API could resemble other server plugin APIs (Bukkit, Sponge, etc.), but these have 2 general drawbacks observed over time:

    • They tend to be tied to the Minecraft version, and Feather aims to be a multi-protocol server. The Material enum comes to mind as a major hassle for forward-compat, and feather does something similar with the Item enum.
    • They make assumptions about single-threadedness, especially Bukkit, because they are tied to the Vanilla server architecture.

    Also, not sure if this would be any major issue, but panics would have to be handled gracefully by the server when triggered by a plugin (especially in event handlers).

  2. caelunshun commented on Sep 2, 2019

    @caelunshun
    MemberAuthor

    Something to consider is the design of the API could resemble other server plugin APIs (Bukkit, Sponge, etc.), but these have 2 general drawbacks observed over time:

    • They tend to be tied to the Minecraft version, and Feather aims to be a multi-protocol server. The Material enum comes to mind as a major hassle for forward-compat, and feather does something similar with the Item enum.
    • They make assumptions about single-threadedness, especially Bukkit, because they are tied to the Vanilla server architecture.

    Yes, we can't have the API mimic Bukkit/Sponge very closely in a lot of ways, mostly because the server needs to know what dependencies an event handler has so it can correctly dispatch systems in parallel. As a result, we can't have, for example, a Player type with methods like send_message and position, because each method accesses different components or resources, and there is no way to know which of these methods an event handler will use.

    Also, those APIs all follow a very different paradigm from what we are forced to do in Rust—there's global state everywhere, and practically every object has access in some way to the entire server state. On the other hand, the Rust API must be more loosely coupled, with each bit of functionality requiring a separate type. I don't think there's a practical way around this.

    Also, not sure if this would be any major issue, but panics would have to be handled gracefully by the server when triggered by a plugin (especially in event handlers).

    We can use std::panic::catch_unwind() for this. Of course, we won't be able to catch all fatal errors caused by a plugin—for example, they could easily just segfault the process using unsafe. The only way around this would to be to go the WebAssembly route.

  3. MarkMcCaskey commented on Sep 3, 2019

    @MarkMcCaskey

    Hello!

    This is a cool project and I'm excited to see how this goes! Wasmer still has some bumps that we're trying to work out, but feel free to ask questions or file issues if you have any. It seems like Instance not being Send + Sync is a major blocker though.

    I just wanted to make a brief note:

    Passing data between plugins would be largely inefficient, since it would have to be copied between the server heap and the WASM module's memory.

    This is something that will be solved with the reference types proposal in the future. This will allow the host to pass an opaque reference to typed data to the Wasm to prevent copying of large amounts of data. The same technique can be used today in the opposite direction, the host can get a reference to Wasm memory (though the Wasm program can't safely execute while this reference is alive because it could invalidate the memory or resize its memory).

  4. arlyon commented on Sep 4, 2019

    @arlyon

    There is scattered talk in the amethyst engine project about some plugin system. I am personally quite keen on the wasm route which, since the two projects run on specs, could mean some of the core ECS interaction could be reused across them.

    amethyst/amethyst#1729 + amethyst/amethyst#1892 has some discussion, with more on their forums

    Reference types seem fairly critical for performance here, and interface types for ergonomics, both of which are coming soon™

  5. MarkMcCaskey commented on Sep 4, 2019

    @MarkMcCaskey

    @arlyon Thanks!

    I'm also excited about the use of Wasm as a plugin/scripting system for games!

    I hacked together a wasmer + specs hello world example and posted it here. I'd like to get your feedback on it.

    Reference types seem fairly critical for performance here, and interface types for ergonomics, both of which are coming soon™

    So I was wrong before, the feature that would allow us to prevent copying is actually separate from the reference types proposal and as a stable feature, neither that nor interface types are really that close. The blog post from Mozilla about interface types came out a handful of days after the name was decided, it's still very early days for it and the existing prototypes are unfortunately still very limited.

    Luckily, WIT can be used to hide a lot of details, so once it becomes more stable, it will hopefully be able to make this process much nicer. Wasmer has a number of opt-in non-standardized features which we're adding to, but it's important to note that because they're not standardized, and some of them are in the early stages, the probability and frequency of major breaking changes when using them is likely very high. We'll do our best to keep the experience of using Wasmer as smooth as possible though.

    In order to get Instance or something like it to be Send and Sync for use in specs, it seems like we'll have to do some fairly non-trivial internal changes; I'll post publicly about this as we learn and do more here.

  6. caelunshun commented on Sep 5, 2019

    @caelunshun
    MemberAuthor

    Looks like WASM is the preferred way to go, so I'll update the proposal shortly.

    @MarkMcCaskey quick question: is there a way to pass immutable memory to a WASM module? I was considering how to pass e.g. a ReadStorage to a plugin so it could access any entity's position, and the only way I could think of was to pass an opaque pointer to the plugin and then pass that pointer to functions on the host. For example, in the plugin API:

    extern "C" {
        fn positions_get(storage: *mut (), entity: Entity);
    }
    
    #[repr(C)]
    pub struct Positions {
        inner: *mut (),
    }
    
    impl Positions {
        pub fn get(&self, entity: Entity) -> Option<Position> {
            positions_get(self.inner, entity)
        }
    }

    And then on the host:

    // Note that this does not account for ABI instability
    extern fn positions_get(storage: *mut (), entity: Entity) -> Option<Position> {
        let storage = unsafe { std::mem::transmute::<_, *mut ReadStorage<Position>>(storage) };
        storage.get(entity);
    }

    However, this opens the possibility that a plugin could mutate the pointer and thus cause undefined behavior on the server. Is there any way to prevent this?

  7. MarkMcCaskey commented on Sep 5, 2019

    @MarkMcCaskey

    is there a way to pass immutable memory to a WASM module?

    That's a good question with some complex answers.

    The short answer is that in standard, sandboxed Wasm, No. That is not currently possible. To read or write host memory.

    The longer answer is:

    Wasm currently only supports 4 types: u32, u64, f32, and f64. So there's no way to even communicate to it that what you're passing it is a pointer outside of its memory. In the future, through multiple proposals we'll be adding opaque reference types which the Wasm can't do anything with but accept and pass along (they can't compare them, or enumerate them, or really interact with them at all). After that, there are plans to add higher level types (maybe still part of the Garbage Collection proposal?) like hashmaps and arrays to Wasm. These two can then be combined by a third proposal that allows us to pass an opaque reference to host data that the Wasm has to interact with safely.

    The hope is that as things like interface types become more real and start to stabilize, we'll be able to hide this, so things can improve in the background while the user interface stays constant. I think it's unlikely that interface types will become significantly more stable in the short term. Wasmer has some (relatively) old experiments for generating host bindings, which as I understand it, were part of what eventually became the current draft of WebAssembly Interface Types. I don't have a ton of context here, but due to the growing excitement I think we're going to expose some of that soon behind some scary --not-our-fault-if-your-code-breaks flags, similar to what we do with SIMD today.

    There actually are a few unsandboxed implementations of Wasm out there which can access host memory, probably either by just not having their own linear memory or through special instructions or something. That's effectively equivalent to executing arbitrary native code though.

    So tl;dr is that currently things have to be copied. We'll probably be adding some features in the near future to hide the copying from you in some cases and if your tolerance for instability and breakage is high enough, then we can probably even make it fast by sharing immutable slices of host memory in the not-too-distant future.

    Additionally, anything larger than a u64 or u128 if you're using SIMD, needs to be passed by reference. This means you'll have to do a whole memory management system. We also support embedding WASI / modified WASI as a target which does its own memory management (https://github.com/wasmerio/wasmer/blob/master/examples/plugin.rs). However this is not an officially supported use case yet because you have to call the main function for WASI's internal data structures to be set up correctly. It does make porting existing programs to your system easier though. Things like printing to stdout just work and you can even redirect stdout to your own WasiFile implementation. Our API is a bit unstable due to how new it is and the official name of WASI's ABI right now is wasi_unstable so, expect breakage.

  8. caelunshun commented on Sep 5, 2019

    @caelunshun
    MemberAuthor

    Thanks for the answer. If I understand correctly, this means that at the moment, there would be no secure way to pass opaque pointers to plugins.

    The key issue here is that there is no way to allow plugins to call functions capable of accessing server state. For example, a plugin might call a function send_message which sends a chat message packet to a player, but there is no way for send_message to send the packet without having access to a component (NetworkComponent, in this case). As a solution, we could copy NetworkComponent into and back from the WASM module. However, there would still be no way for the plugin to obtain a NetworkComponent for an arbitrary entity, since this would require calling a function on the host with access to ReadStorage<NetworkComponent>.

    For now, I guess we could just use the opaque pointer technique above and accept the security issues which come with that (besides, most other server implementations don't sandbox their plugins at all). We could then switch to using one of those WASM features once they are stable.

  9. MarkMcCaskey commented on Sep 5, 2019

    @MarkMcCaskey

    So currently Wasmer doesn't implement the unsandboxed memory mentioned above, only a few small Wasm runtimes do as far as I'm aware because it's effectively just running normal code. We also don't currently have the reference types proposal implemented; I think the simplest stop-gap solution is to do mass copying. I think in practice it probably won't be that slow, but it will depend entirely on your access patterns.

    In the example above of having a Wasm module that sends a message, a simple way to do this might be to have a message queue and a host-call that copies the string from Wasm memory and pushes it onto the queue. You can then have something concurrently processing the queue, either separately or as part of the normal ECS execution.

    The Wasm module in this case could execute other host calls to ask for the data it wants, or you could preemptively copy it over if you know that it will always need it.

    So if you know that this message sending system needs to have access to all connected players, you could copy that data over (either at initialization of the Wasm module and then give it updates like "player1 disconnect", "player2 disconnect"; or by copying everything over every time it runs). Then if the message sending system needs to check conditions based on the contents of the player's inventories, it could call the host to query for specific items of a player or to get the entire inventory copied into its memory. From there it can do its logic and execute other host calls for side effects (like pushing a message onto the queue).

    Let me know if I'm missing the purpose of the plugin system. There are actually a number of different patterns for using Wasm to execute logic in a larger system. The one I mentioned in this comment is orthogonal to the ECS.

  10. caelunshun commented on Sep 6, 2019

    @caelunshun
    MemberAuthor

    Yes, that's similar to what I meant. The problem I refer to, though, is that a host call has no way to access, for example, a player's inventory, without having a ReadStorage<InventoryComponent> passed to it as a parameter. IMO, the best solution for that right now would be to use the opaque pointer strategy and do any interaction with the data behind the pointer through host calls. This way, the server can transmute the pointer and access e.g. the player's inventory, copying the requested item into the WASM module's memory.

    From what I can tell, copying an entire component storage into a WASM module's memory each time a plugin needs access to a couple of components is impractical—we're talking about potentially megabytes of data, and the plugin might be called over 20 times per second. The opaque pointer solution solves that at the cost of security, unless I'm missing something.

  11. MarkMcCaskey commented on Sep 6, 2019

    @MarkMcCaskey

    Okay, thanks for explaining that! I think I understand: we don't need opaque pointers or any memory unsafety for this to work and it can work with what we have right now.

    In Wasmer, you can store data in the Ctx (for WASI we use this for the file system, program arguments, and environment variables). All host-calls take a &mut Ctx as their first argument. So any host-call can perform filesystem operations this way. In this case, rather than passing a host pointer into wasm memory and getting it back out (something that's also possible in Wasmer today, but memory unsafe because I can, for example, just give you a null pointer instead), you can simply use an identifier that can be used to find what you're looking for in the Ctx's data or from the larger system.

    We could use a HashMap or a Vec in the Ctx's data and pass in either the key or an index and then the Wasm can say that it wants to do operation X on data Y. If the handle the Wasm gives you is invalid, you can ignore it and/or return an error code to the Wasm. The one downside to this right now is that the Wasm can forge these handles. So if you want to limit permissions, that has to be done as an extra step.

    // create MPSC up here
    let state_gen = move || {
            fn state_destructor(data: *mut c_void) {
                unsafe {
                    drop(Box::from_raw(data as *mut FeatherWasmState));
                }
            }
    
            let state = Box::new(FeatherWasmState {
                data: vec![read_storage_inventory],
                message_sender: sender.clone(), // from outside closure
            });
    
            (
                Box::into_raw(state) as *mut c_void,
                state_destructor as fn(*mut c_void),
            )
        };
        let imports =
        imports! {
            // This generates the Feather Wasm state.
            state_gen,
            "feather" => {
                "send_message" => func!(send_message),
                "get_inventory_item" => func!(get_inventory_item),
            },
        };
    
        /// This function is unsafe because it does not check if `Ctx` is a Feather `Ctx`
        pub unsafe fn get_feather_wasm_state(ctx: &mut Ctx) -> &mut FeatherWasmState {
           &mut *(ctx.data as *mut FeatherWasmState)
        }
    
      fn send_message(ctx: &mut Ctx, message: WasmPtr<u8, Array>, message_len: u32) -> u32 {
         let memory = ctx.memory(0);
         let wasm_str = message.get_utf8_str(memory, message_len).expect("TODO: error handling");
         let feather_state = unsafe { get_feather_wasm_state(ctx) };
         feather_state.sender.send(wasm_str.to_string());
    
         0
      }
    
       #[repr(C)]
       pub struct Item {
          // if the struct has nested allocations (i.e. Vec or String), then passing it back gets more complex
          // we can have the call take multiple pointers, have the call take a single pointer and sub divide it, have the call itself allocate memory from the Guest, or have the call allocate its own memory in the guest
          // because I'm writing this directly in the GitHub comment box, I'm going to keep it extremely simple
          item_name: [u8; 32],
          value: u32,
       }
       // tell Wasmer that it's okay to store/read this type to/from little endian bytes
       unsafe impl ValueType for Item {}
    
       fn get_inventory_item(ctx: &mut Ctx, player_id: u64, item_id: u64, item_ptr: WasmPtr<Item>) -> u32 {
          let memory = ctx.memory(0);
          let feather_state = unsafe { get_feather_wasm_state(ctx) };
          let output = item_ptr.deref(memory).expect("bad pointer");
    
          // in this case we know what we need because of the name of the call, but we could
          // accept an arbitrary index if we wanted something more dynamic
          let item = feather_state.data[0].get_item(player_id, item_id); // glossing over all the details of how you'd get this out of the ECS
    
         // if our type is simple and repr(C), we can just use it directly
         // otherwise we have to do more work here
         output.set(item);
         
         0
       }

    I quickly wrote up some code for what that might look like. This code won't compile as-is, but it's not too far off of what the real code might look like. This example is pretty simple though.

    Hopefully this example can help align us a bit better. I agree 100% that copying over component storage is the wrong thing to do most of the time. That said, accessing component storage from multiple threads already involves a ton of copying of all those megabytes, so I'd encourage simplicity via copying first and optimizing as needed because it may turn out that the simplest solution is good enough.

    Please let me know if my example isn't what you're talking about. If we can iterate on something more concrete, like this pseudo/real code then I can probably understand better.

  12. caelunshun commented on Sep 6, 2019

    @caelunshun
    MemberAuthor

    Ah, that's exactly what I'm talking about. I didn't know that host calls take &mut Ctx as a parameter—that helps a lot.

    Sorry if I wasn't able to get across what I meant.

    Thanks for the help!

  13. MarkMcCaskey commented on Sep 6, 2019

    @MarkMcCaskey

    No problem!

    I'm happy to help! We're currently investigating making some large internal changes and as part of that we need a better sense of how Wasmer will be used so we can make sure we support important use cases well. A fresh set of eyes and a real world use case are very valuable! This seems like a good testing ground and I'm impressed with this project so far!

    Let me know if you want to talk through designs or if I can help out with something.

  14. caelunshun commented on Sep 7, 2019

    @caelunshun
    MemberAuthor

    I've been trying to come up with an ideal way to handle interactions between Specs and plugins, and I believe I've found a decent solution.

    First, a custom scheduler/dispatcher will be implemented and used in place of specs::Dispatcher, at least for plugins. This scheduler will work like the Specs scheduler, with the following differences:

    • A system does not specify its SystemData; rather, it is just passed a World handle from which it can fetch resources, components, and entities.
    • The scheduler maintains a list of resources which each system is known to use. When a system is first added to the scheduler, the scheduler initializes this as an empty vector.
    • When a system attempts to access a resource which is already in use, it notifies the scheduler through a channel. The scheduler then waits for the necessary resource to become available and notifies the system with the resource. The key part here is that the scheduler will add the requested resource to the list of resources required by the system. As a result, future dispatching will take into account the required resource, ensuring that this slow exchange never occurs again.

    The main idea here is that systems will know longer specify their required resources at compile time; instead, any requested resources will be lazily added to the dependencies of the system. This allows for much more versatile scripting, because a script will be able to access any component it likes without specifying that it requires access to that component. Since systems typically use the same resources on each cycle, only the first call will incur the overhead of obtaining the resource through the scheduler; any future calls will be guaranteed to already have access to the resource.

    A system running on this scheduler might look like as follows. Note that a new joining API would have to be written for ergonomics, perhaps looking something like Legion's querying system.

    pub struct PhysicsSystem;
    
    impl System for PhysicsSystem {
        fn run(&mut self, world: &WorldHandle) {
            let query = <(Write<PositionComponent>, Read<VelocityComponent>)>::query();
            for (pos, vel) in query.iter(world) {
                pos += vel;
            }
        }
    }

    When the query is performed, MaskedStorage<PositionComponent> and MaskedStorage<VelocityComponent> will be fetched from the World; if they are not available, the scheduler will be notified.

    The basic flow of this is as follows:

    • A plugin's init function is called, and it requests PhysicsSystem to be registered over the WASM interface.
    • The scheduler adds the system to its internal data structures, initialized with no system data at the start.
    • The first dispatching cycle is run.
    • The system accesses storages for PositionComponent and VelocityComponent; it notifies the scheduler in order to obtain them. The scheduler now knows that PhysicsSystem requires access to those two resources.
    • Future calls to PhysicsSystem will account for the two dependencies, ensuring that the resources are always available to the system.

    As for the overhead of utilizing such a design, I would expect performance to be slightly worse, but not by that much. The main overhead would be on the first run of the system, because all resources would need to be requested from the scheduler. However, any future runs should, theoretically, perform just as well as systems using specs::Dispatcher.

    The only slight performance decrease after initial running would be that using the same resource twice would require two calls to World::fetch (a HashMap access), while normal Specs systems would have the value cached. However, I believe this is a minimal overhead for the benefits a scheduler like this provides.

    Beyond a normal plugin system, using this idea would potentially allow for implementing a compatibility interface with the Bukkit API, something I had never even dreamed of being able to do with Specs.

    I'd like to know what people think about this idea.

  15. MarkMcCaskey commented on Sep 10, 2019

    @MarkMcCaskey

    @caelunshun Thanks! That sounds very interesting. I've been delaying responding to give myself time to process this more in the background for a bit.

    The idea of a dynamic dispatcher is interesting and something that I didn't realize was possible with specs. There are a couple of new problems this will introduce, but I think we can solve them. For example, deadlocks are now possible with the ability to dynamically request resources, so we'll have to have a way to update scheduling. An immediate problem with that is partial transactions: if System A requests resources 2 and then later 1 and makes changes to data via its access to 2, and System B requests resources 1 and then later 2 and makes changes to data via its access to 1, then you're in a potentially invalid state if either system stops thus resulting in an unresolvable deadlock.

    A classic solution to solving deadlocks is to enforce acquisition order. In this example, numerical or alphabetical order can be used to ensure deadlocks are not possible. Along the same lines, we can solve this by requiring all new accesses to locks to be atomic and require that the requestor has no locks out. What I mean by that, is that if you request locks 2 and 1, we can order them. This is limiting and doesn't fully solve the issue of a partial transaction.

    Aside from the deadlocks, two systems competing for access to data where at least one is mutating it can cause instability. It's not a proper race condition if it's synchronized correctly, but it's a logical race condition that can make execution non-deterministic.

    I think for third party scripting systems, the most common answers to the "logical race condition" problem are 1. Not my problem or 2. Run them sequentially / in a defined order.

    A design that I'm quite fond of in theory which kind of side steps some of these problems is an event based system where rather than scripts executing consistently and deciding if they want to do anything, they subscribe to certain events (generated by the ECS and stored in lock-free containers in the ECS resources) and then get called in a specific way to handle that event when it happens at the end of the normal ECS execution. This is strictly less flexible and requires more work on the host side, but it allows the host to call the scripts in a way that may significantly reduce data contention. For example, the event the script receives may contain most of the data that could be relevant to that event so reasonable scripts won't have to ask for more data. (This can still lead to conflicts of mutation where 2 scripts mutate the same data point in an incoherent, but well-defined way because they saw "last frame's data")

    Other options for dealing with contention on mutation is to store views of the current state and a list of mutations that the scripts wanted to do and then the scripting system can check for conflicts and apply some of the mutations and then rerun the scripts with conflicts in a defined order. And if we were really clever, we could hold on to that knowledge for the next time we dispatch the scripts.

    Compatibility layers are actually a major use case for Wasm. In the not-too-distant future, running Wasm from Wasm will be common. The way this would work is that one Wasm module would export the existing API and then implement it in terms of the host API. This is particularly powerful because it can be chained as much as you want, preventing lockin to certain APIs or game engines. There is a runtime cost to these, but working more slowly (which may be good enough) is far better than not working at all.

    Anyways, I'm very interested in the idea you proposed, it's kind of like implementing an extra ECS on top of the existing one, but seems like it could be a proper solution to the problem. Though if we can make the scripts tell us exactly what resources they might need up-front, then we can probably save a lot of engineering work. The problems I've talked about here don't have much to do with Wasm, they're generally applicable to concurrent, dynamic ECS design.

  16. caelunshun commented on Sep 24, 2019

    @caelunshun
    MemberAuthor

    @MarkMcCaskey Ah, the deadlock problem prevents the whole idea from working correctly. I should've thought of that.

    Dynamic systems already work with Specs; see for instance this example. Plugin systems would be equivalent in functionality and dispatching with systems on the host, since they will be registered with the DispatcherBuilder at initialization time. The scheduler design I proposed was only an attempt to prevent plugins from having to specify which system data they require. I do agree that it will be a lot easier if we just require plugins to specify their required system data.

    Now that wasmer::Instance implements Send, I'll update the proposal and move forward with the WASM route. Thanks for your efforts!

  17. MarkMcCaskey commented on Sep 24, 2019

    @MarkMcCaskey

    @caelunshun That's interesting! I didn't know that specs could do that. I don't have full context on shred, or specs really, but it seems like it still has the potential to deadlock or have logical race-conditions if ran in parallel or with any non-dynamic system running concurrently, the example runs the scripts after the main logic.

    Wasmer allows dynamic function calls with a variable number of arguments that will fail if the wrong number of arguments are provided, so it looks like it could be used more or less directly here as long there was an extra step for dealing with converting the types into Wasm-types. I believe dynamic calls are slower than static ones in Wasmer, but it seems like a reasonable place to start given how flexible it is.

    Yeah! I'm excited about it! If something else comes up, I'd love to hear about it!

    I just read the edited comment at the top: one thing to note is that it's possible to have parallelism through multiple instances. The way this would work is that the data they operate on is where the memory synchronization happens. So the trivial way to do this is to put a Mutex on the shared global state that the plugins can interact with. Things can get tricky here, it's something we need to test more and document. One last note, a neat benefit of Wasm is that your sandboxed plugins can have sandboxed plugins! That's something we can talk about later in the context of the prototype if you're interested!

    edit: in response to the top of my comment, I see you mentioned declaring resources up front. If that's the case, then the scheduling becomes easily solvable and we may be able to use static wasmer functions.

  18. added this to the 0.7 milestone on Oct 5, 2019
  19. ambeeeeee commented on Mar 5, 2021

    @ambeeeeee
    Contributor

    Closed - Implemented and not the place for future plugin discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions