Comments (13)
I don't think cgo has any problems.
As for complexity, cgo only appears under the hood. The default wasm runtime in our project is wasmer-go, so that users do not need to write any cgo codes by themselves.
As for performance, in our env, a go->c
cgo call cost only ~60ns, it does much slower that nativa go->go
/c->c
call, but it can be ignored in proxy case, which usually cost ~ms for one request to be done.
Moreover, the wazero project do not provide any benchmark data, such as pure go wasm runtime vs cgo wasm runtime, so it can not convince me about their so-called performance.
If you insist on supporting the wazero, welcome to open up a PR to integrate the wazero runtime, just like what we do in https://github.com/mosn/proxy-wasm-go-host/tree/main/wasmer, it not a difficult task :-D
from proxy-wasm-go-host.
After a quick glance of the wazero project, I find that it's just another wasm runtime, just like V8, Wasmtime, Wasmer, WAVM, etc. The main difference is that the wazero is implemented in pure Go, so that it can get rid of cgo. However, its support on wasm core specification is not as good as other runtimes, such as Wasmer. So do we have any good reason to support the wazero runtime?
from proxy-wasm-go-host.
it can get rid of cgo
from proxy-wasm-go-host.
Does cgo bring any problems?
from proxy-wasm-go-host.
The main advantage or feature is this
https://github.com/tetratelabs/wazero#history-of-wazero
from proxy-wasm-go-host.
ps I noticed this issue, and wazero does have benchmarks, just we let people run them on own. For example, our build breaks if the benchmarks are ever slower than wasmtime wasmer or wasm3.
ex they are run on every commit. Not sure how many others do that
https://github.com/tetratelabs/wazero/runs/6094956125?check_suite_focus=true
from proxy-wasm-go-host.
Ex you can run make bench.check
if you like, or execute the vs directory yourself. Here's an example from the above CI run.
goos: linux
goarch: amd64
pkg: github.com/tetratelabs/wazero/internal/integration_test/vs
cpu: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
BenchmarkFac_Init/Interpreter-2 53996 21683 ns/op 11960 B/op 370 allocs/op
BenchmarkFac_Init/JIT-2 8391 151112 ns/op 62045 B/op 1251 allocs/op
BenchmarkFac_Init/wasmer-go-2 1999 598627 ns/op 1232 B/op 41 allocs/op
BenchmarkFac_Init/wasmtime-go-2 1938 622997 ns/op 345 B/op 21 allocs/op
BenchmarkFac_Init/go-wasm3-2 137173 8501 ns/op 168 B/op 11 allocs/op
BenchmarkFac_Invoke/Interpreter-2 118746 9963 ns/op 2096 B/op 129 allocs/op
BenchmarkFac_Invoke/JIT-2 806187 1349 ns/op 1216 B/op 5 allocs/op
BenchmarkFac_Invoke/wasmer-go-2 730215 1688 ns/op 176 B/op 12 allocs/op
BenchmarkFac_Invoke/wasmtime-go-2 354572 3711 ns/op 256 B/op 20 allocs/op
BenchmarkFac_Invoke/go-wasm3-2 484650 2504 ns/op 56 B/op 5 allocs/op
BenchmarkCodecExample/binary.DecodeModule-2 233971 5060 ns/op 2440 B/op 109 allocs/op
BenchmarkCodecExample/binary.EncodeModule-2 240770 4950 ns/op 3960 B/op 124 allocs/op
BenchmarkCodecExample/text.DecodeModule-2 50046 24196 ns/op 8560 B/op 369 allocs/op
BenchmarkCodecExample/wat2wasm_via_text.DecodeModule->binary.EncodeModule-2 40120 29765 ns/op 12528 B/op 493 allocs/op
BenchmarkCodecExample/wat2wasm_vs_wasmer.Wat2Wasm-2 24598 48232 ns/op 2704 B/op 6 allocs/op
BenchmarkCodecExample/wat2wasm_vs_wasmtime.Wat2Wasm-2 29388 40440 ns/op 2672 B/op 3 allocs/op
PASS
ok github.com/tetratelabs/wazero/internal/integration_test/vs 23.480s
In any case, I think it is a better fit for folks who desire specific things that are impossible otherwise. Ex multi-platform builds, transparent debug story (ex no clib blackhole), coherent trace context propagation etc. If these things aren't relevant and you're otherwise happy where you are, maybe best to stick with it. Meanwhile, good luck wherever you end up!
from proxy-wasm-go-host.
ps also maybe not relevant to you but image size in proxies is sometimes a problem. Wazero can be 3MB total in docker, and I think that's pretty impossible in any of the alternatives tetratelabs/wazero#424
from proxy-wasm-go-host.
one last spam. I learned a lot reading this on CGO it does a great walk through of things in a different way than the usual "CGO is not go" blogs. Hope it helps you decide not so much if wasmtime should be in here, but more should CGO be the only way to use wasm in the project. https://speakerdeck.com/jcchavezs/cgo-journey-from-using-to-understanding-it
PS it is ironic this issue exists because months ago I thought exactly mosn would be a good thing to try to work in wazero, especially for unit testing proxy plugins without any hassle or weird windows things etc. just thought it would be cheesy to make an issue to suggest it, being that I'm a maintainer. I'm glad someone else raised this, so I had an excuse to spam you all these comments. But don't worry, that's all unless you ask for more 😎
from proxy-wasm-go-host.
#19 but I think we can do a lot better as noted at the end of my description. The attempt to abstract things forces things to require wrapping and reflection, the performance impact is really bad and also the code is harder to follow vs doing things directly. Later I'd be open to rewriting it to be direct and fast if you like.
from proxy-wasm-go-host.
#27 will add this. we've figured our way through a misunderstanding. Notably, it is ok to fix the v2 and also wazero made a concession to allow the unsupported wasi_unstable
to work as some old code may never change.
from proxy-wasm-go-host.
@pretty66 once mosn/mosn#2172 is merged "wazero" is a valid engine choice in mosn config!
from proxy-wasm-go-host.
@pretty66 v1.3.0 mosn is out and includes this now. thanks for your patience and all the support from @antJack and @taoyuanyuan!
from proxy-wasm-go-host.
Related Issues (10)
- BufferType extension should be support
- Imports/exports don't match expected Proxy-Wasm ABI versions. HOT 4
- go get mosn.io/proxy-wasm-go-host/proxywasm/common is failing HOT 4
- Not able to add header element. HOT 3
- When call ProxyOnRequestHeaders get wrong action HOT 5
- Drop ABI v0.1.0 HOT 9
- Change example to use currently maintained ABI (0.2) HOT 1
- err: "proxy_set_buffer_bytes" is not exported in module "env"
- Add CI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proxy-wasm-go-host.