-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
WebAssembly plugins system #122
Comments
I think the most basic demo would be implementing one of the existing commands in such a way, e.g. helix/helix-term/src/commands.rs Lines 123 to 137 in 407b37c
It only depends on the Context , and it only uses functions from core (move_horizontally) without interacting with the UI. I think most of the primitives in core should be exposed (selection/range/transaction/etc) and we can have a subset of view exposed (retrieving a selection from a doc, applying transactions)
|
Mentioned on Matrix:
|
What benefit does this provide over binary plugins? Will plugins be able to access eachother's state (functions, variables etc.) in the same way that plugins programmed in a single language (e.g. emacs) are able to, or something else? My bad if the answer is obvious btw. I'm not very familiar with WebAssembly or plugin architectures. |
I think this post explains it well. There's a lot of uncharted ground in regards to plugin systems, especially with sharing state, but you can see past discussion on this here. |
@kirawi |
If you want to embed the wasm compiler with the binary or as library etc, I would advise against wasm due to slower speed and missing performance optimisations on many targets. "Of course, wasm3 runs fine on aarch64, but at about 3% of native speed." This benchmark shows very astonishingly the missing optimisations that luajit can do here using this lua libary. Also it would be advisable to have execution time benchmarks of webassembly against all usable alternatives before making a decision (ie by listing some speed and platform compatibility requirements). Would be not very useful to end up with something significantly slower than neovim. |
The intention is to use Lua lacks multithreading, SIMD, and has a smaller ecosystem. It's a lot more convenient to enable users to opt for their favourite language rather than have them learn a separate language and its ecosystem. I can't speak on behalf of everyone, but I believe that most Rustaceans firmly agree with me, as many libraries have wasm as a compile target. I would say we collectively have a lot more experience with wasm as a whole. |
We'll probably go with
Given that Cranelift code generator is still very young and already that good, I'm not too afraid. Furthermore performance tracking is a thing at the bytecodealliance. Besides all the other good points made by @kirawi on performance, I really like the ecosystem argument which is the reason why we want to use WASM in the first place. Given that performance is probably good enough (or more than enough), the main focus should be on whether user/developer experience is good. |
Thanks for considering Wasmer! We are working on a set of benchmarks at the moment, we had two bugs that prevented Wasmer to shine in the one you showcased @CBenoit, but those are already solved in Right now Wasmer is about 20~30% faster than the other runtimes when using the LLVM compiler! In general, we recommend Cranelift if the compilation times need to be fast (that is mainly for development), and LLVM for production (similar to how Rust uses LLVM always to compile in release mode, and Cranelift as an experimental compiler for faster compilation times in debug mode) :) |
This is a question I've had for a while, but what is the main difference between |
Thank you @syrusakbary for your input!
I'm interested in hearing more as well! I was more in favor of
On the other hand,
I'll also ask on Veloren's Discord why they decided to use I also found this article published a few months ago:
|
@CBenoit @kirawi There are 2 mutual exclusive possible use cases for WASM for plugins, where one really wants to have a plugin manager: 1. shipped compiler or 2. hook into the repo build system and the used compiler to build the WASM libraries/binaries.
Solution 1. gives more of a "it always works" experience with the language that the compiler supports Solution 2. gives more of a "its super fast", but needs some setup and might break. Unless you can use nix for 2. ie with flakes 2 is just painful due to 2.1 many distros not shipping all compilers or only specific versions and then you are stuck on one (ie not yet stable languages) and 2.2 you want to simplify build system stuff for plugin developers. nix with flakes is the de-facto best solution for 2.1 (shipping compilers+libc(s)? and make sure they exist, are configured/build identically and up-to date enough for the plugin ecosystem). Ask yourself which solution is better for the goals of the project helix or how you want to deal with the mess of 1. shipping compilers and 2. supporting the build systems of plugins. |
We won't be shipping a compiler, though? WASM is a compile target for Rust itself as Did I understand you correctly? |
@kirawi How does this change the problem, when the plugin is written in a language that the distribution doesnt ship a compiler (or super old/incompatible or slow libc etc) ? |
No, it's just |
@kirawi Thanks alot for the clarification. How is 1.integrity (nobody tampered with the build process/environment), 2. debuggability/tracebility (what stuff got wrong) and related 3. uniformity (potential contributors can reproduce the Point 1. is a stopper for usage in any more security-critical developer environments, point 2. is okayish not to have (debugging luajit also doesnt work very good), point 3. can be super annoying to find contributors. |
The same challenges exist for any language, but Wasm is a compile target, not a language, allowing for anyone to write any plugin in any language they want, instead of restricting them to one. |
|
Indeed, but that is something that is just going to happen no matter what. Every program that people use is going to be written in separate languages, and if you want to do that of risk analysis, you would want to compile it yourself. But the other benefit is that since you can write a plugin in your preferred language, you can for the most part write all your plugins in-house. Lua is arguably worse because it lacks sandboxing, while with Helix and Wasm we would have full control over what a plugin can or cannot do. It's a tradeoff for sure, but I think Wasm opens up a lot of possibilities to circumvent the cons of using Wasm. |
@kirawi How much performance loss does sandboxing mean? L3 cache can likely never fully be mitigated without notable performance loss, since it is shared between cores (and mitigation would require accurate time synchronisation between memory controllers of cores). Here is the list of possible cache attacks which looks scary to me. |
Just being on the browser right now, you're probably running quite a lot of JavaScript and Wasm already. I think this discussion, though important in general, is bike shedding in this context. There isn't a perfect solution here, and there probably never will be, but Wasm seems like the best option for Helix. |
Can we have two in one option? On one hand we let developers have it compiled so it could be faster. On the other hand we can have it interpreted to allow testing stuff faster. We could use the interpreted version as one of the compiled plugin. Not sure how feasible is this. |
That's definitely some workflow we could think of at some point. Makes me think of the gcc-emacs that is compiling elisp instead of interpreting it IIRC. I prefer investigating the embedded runtime approach fully before we consider that though. |
Just for clarification. Wasm3 is 4-5 times faster than, say, Python 3.9, yet weights only ~150KB. On Apple M1 for instance, it showed ~5-7% of native speed, which is somewhat better than 3% that was claimed here. |
Today in the news: https://wasmer.io/posts/wasmer-2.0 Seems to have some support for reference types. I'd still like to see a comparison with wasmtime beyond just performance. (Edit: Nice, I see the announcement is written by @syrusakbary himself) |
Personally VSCode is far from what I'd describe as an editor that I need no plugins for at all. The only thing it has going for it is built-in JS support which I'd expect given it's literally running in a browser... And I'm not saying that it's a bad thing. Off the top of my head - I use the pijul VCS, I think it's great and I'd love to have at least some basic integration in helix but I know that I'm in the minority and the vast majority of users don't. Same with more niche languages which rely heavily on custom LSP extensions. Sure, I can add a custom language definition in helix but it won't support all the features I could expect out of other editors and it's not something I think should be welcome in the main codebase. That's why I'm also in favor of at least "recommended" plugin repositories or having the "official" plugin repo but for the tinkerers or people wanting to live on the edge have the option to extend helix themselves or with not-officially-supported plugins without having to maintain a personal fork. |
@nrabulinski Yeah, +1 for Pijul version control. Finally I see somebody mentioning tooling support somewhere. Also, the support for less popular languages is important. There are some amazing languages out there (e.g. Zig, or Crystal, and not having support for these would @eulerdisk, including Lua is the worst idea ever. I think we need a plugin system which supports plugins in any language. This opens up the opportunity for everyone to write plugin in their favourite language, and also other new approaches, like languages specifically designed for text editing. There are two approaches that can fulfill these requirements: WebAssembly, and native binary plugins. (Sorry if I repeated points that were mentioned before, I just found this software, and haven't followed the discussion before.) |
@eulerdisk Then you should probably go with IDEs. |
Implementing everything in core is a mistake! |
Maybe a good topic in lieu of or in supplement to this conversation would be a list of features the community wants, and a discussion on whether each is best suited to a plugin or core implementation, because I feel like each opinion that a plugin system is required is not really that interesting without saying, "Here is a feature I want, that I will make a plugin for, that definitely shouldn't be included in the core distribution." Failing that, I'm not sure what we're talking about. For me, I think very tight git integration akin to magit... but I think if something like this were planned as a core feature it wouldn't require a plugin. |
@theherk Counterpoint, while I think your question is interesting, ultimately I think it's irrelevant because the whole point of a plugin system is so that anyone can decide for themselves what they need. Maybe someone has some niche use-case that they need a personalized tool for; they can script it themselves. And if it so happens that multiple people agree that a particular tool is important then maybe they can collaborate on one. Yours is a good question for maybe brainstorming but ultimately I don't think it's as crucial as establishing that a plugin system is warranted. For me, the specifics would be magit, org-mode, and all the other plugins that make the likes of neovim and emacs useful. There are already plenty of great ideas out there. Whether or not I'm actually going to be using all of those is an open question but I would like the flexibility to decide that for myself. |
@emummel20 I see what you're saying, but I think the main thing that @theherk's suggestion would accomplish is to demonstrate what and how many features there is demand for...I think one of the main reasons (if not the reason) that there are still people who don't think helix should have a plugin system is because they don't realize (or haven't completely thought through) the vast number of features that would have to be in core for a plugin system to be unnecessary. A list of those features might be a wake up call. |
I don't understand why, @emummel20, you think those can only be implemented as plugins. I'm suggesting the can be or they can be implemented as compiled source. If you don't want to use them, there is no reason configuration can't enable or disable features. To suggest that consideration for specific plugins has no bearing on the creation of a plugin system doesn't make sense to me. What I mean is, if for example the community agreed that something closely matching the functionality of magit were needed, implementing it a a plugin would make less sense then building it into the core. Same for org-mode, etc. However, if on this list there were things that only a subset of the community wanted, it would make it clear that such a system is warranted, and further it might help inform how that system should be implemented. I am pretty pro-plugin, but I think a data based approach is the next logical step, and blindly saying "there already exists a binary answer, no further consideration necessary," doesn't really move the needle. editing to expand: As an idea, the author or collaborators could install the github polls app or similar (I guess 👍 / 👎 are also sufficient). Then, we could begin opening issues per requested feature with a poll on if it should be included in the core distribution or not. A page could be added to the Wiki tracking these. It would probably showing quickly that there are many features that many want, but that there isn't necessarily agreement on there inclusion in the core distribution. |
@theherk the part of this equation you're not considering is the maintainers. The more features are in core, the harder it is to maintain. Every new feature adds to a matrix of support, and thus adds exponentially more work over time. Plug-in systems are just as much for developers as they are for the users. The core maintainers cannot possibly maintain every single feature under the sun. And furthermore, as much as everyone would love an ideal world where we could base our decisions purely on data, this is simply impossible with the resources this project has at its disposal. Big companies can do this because they do active customer research, meaning they find and actively solicit feedback from users; they do not wait for customers to come to them. Those who notice and participate in a poll on GitHub is not going to be nearly representative of the entire user base. The vast majority of users are not aware of any part of the development process, nor should they be. And user polls do not represent the other half of the equation (maintainers). You could not possibly hope to gain any statistics meaningful enough to drive roadmaps or design through a Github poll. |
@theherk I didn't say they can only be implemented as plugins. I'm saying that a plugin system is likely the only scalable solution because there are a million plugins that one could want and the dev team for helix is probably going to be too small to either implement everything we might want themselves or review every single pr to merge into the core. Obviously the ideal scenario is that we get everything we want implemented in core but that's a fantasy, and even if we could get a particular plugin in core it still wouldn't be ideal because there are different ways of implementing different features with different tradeoffs and if it's all in core then you're stuck using whatever was implemented with no hope of something else. Consider neovim's major implementations of org-mode: There's this one and this one. Now I haven't used them, I don't know what the differences are between these but presumably there are some and the point is, as a neovim user you have a choice which one you want to use and which one is better for you -- and the only reason this is possible is because two different teams created two different plugins as opposed to one team implementing one core feature set. Do you not think it makes more sense to let the dev team work on making the core editor better by fixing bugs and improving architecture rather than worry about implementing magit? I think there's enough to work to be done in the core platform and if the dev team spread themselves thin working on everything under the sun if would be counterproductive. |
Honestly this issue has so much difference of opinion, no matter what ends up happening, there will probably be a lot of unhappy people. In my opinion, this issue doesn't need more user feedback, it just needs a decision and an implementation. |
did any one check nushell plugins ? |
Just putting lapce out there. |
From that webpage: "Vim users, we've got you covered! Built-in support for a Vim like editing experience, without a plugin." |
Correct, it supports Vim keybindings without a plugin, but it also supports WASI plugins |
Also from that webpage: "WASI plugin system |
@devanlooches: Maybe you have some insider information, but I was under the impression they were only slightly further along by having decided on the definite inclusion of a WASI plugin system. But the API and implementation are very not done. lapce/lapce#558 |
Ah I see. I only took a quick glance and saw it on the website. I was under the impression it was more completely since there was already a crate on crates.io. lapce-plugin |
I believe that this issue would be better served by a proper discussion. I would urge anyone with comments not pertaining to the implementation to use #3806 instead. Additionally, it might be wise to create a new issue altogether for the plugin system. There's a lot of noise here, and focus has shifted from WebAssembly to other alternatives. |
@kirawi Discussion is now fragmented between #122, #3806 and #2949 :/ I also agree with #122 (comment), at this point opinions are being repeated and we don't really need more input, rather development time has to be spent on an implementation. |
I stumbled upon zellij, which has a WebAssembly plugin system implemented, maybe it can be used as a reference. |
It’s mentioned in the very first post. It’s not against anyone, but for now I think it’s best to lock this issue until further concrete progress is made (see #122 (comment) and #122 (comment) for why). Of course, feel free to comment in the discussion #3806 or to join the Matrix Space, just try to not forget using Ctrl-f in this issue beforehand. I’m not locking to prevent any further discussion from users, but rather to make it obvious to everyone that we already collected most of the opinions and suggestions and that what we really need now is development time. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Basically load
.wasm
files.Capabilities:
At first we could use a basic toml config file or CLI to feed .wasm files to the editor.
A way to configure permissions on a plugin basis could be investigated to use the sandboxing capabilities coming with WASM.
Example with
wasmtime
:(reference)
I think the biggest challenge is to get well-defined interfaces down but let's not fear to break it during early stages.
Later we could investigate embedding a wasm-based scripting language such as Grain or AssemblyScript.
Here are some references:
wasmtime
andwasmer
I'm willing to experiment soon
The text was updated successfully, but these errors were encountered: