News for hackers. Stuff that matters.
Re:WASI Support in Go by jsd1982 on Wednesday September 13, 2023 @03:30PM (#37500663)
The go-compiled wasm is also extremely slow compared to tinygo's wasm. Doing simple things like `fmt.Printf()` degraded performance significantly.
Re:WASI Support in Go by alecthomas on Wednesday September 13, 2023 @04:09PM (#37501112)
I wonder if fmt.Printf() in particular is slow due to the CGo transition? Assuming there even is a CGo transition when compiled to WASM...
Re:WASI Support in Go by jbrandhorst on Wednesday September 13, 2023 @04:51PM (#37501557)
There's no CGO involved when compiling to Wasm. The sometimes slow performance is due to the hoops the compiled code has to jump through to support the Go runtime and goroutine preemption on a single thread.
Re:WASI Support in Go by alecthomas on Wednesday September 13, 2023 @06:10PM (#37502377)
I understand there's no CGo specifically, but I'm wondering if the Go runtime when running under WASM still has to manage switching out the goroutine stacks for "WASM stacks" when it's calling out through the WASM VM.

Edit: from this comment [1] it sounds like this is the case.

[1] https://news.ycombinator.com/item?id=37501552

Re:WASI Support in Go by Patrickmi on Wednesday September 13, 2023 @07:46PM (#37503131)
Tinygo runtime don’t have g or m threads that’s why it’s Cgo is zero cost