←back to thread

Show HN: Go Plan9 Memo

(pehringer.info)
302 points pehringer | 4 comments | | HN request time: 0.432s | source

A quick dive into the Plan9 assembly I picked up while developing my SIMD package for Go, and how it led to a 450% performance boost in calculations.
1. lexh ◴[] No.41880231[source]
A bit over my head, but I enjoyed the way the writing brings us along for the ride.

This can’t be the first pass someone has made at something like this, right? There must be literal dozens of SIMD thirsty Gophers around. Would a more common pattern be to use CGO?

replies(3): >>41881085 #>>41881167 #>>41881773 #
2. dpifke ◴[] No.41881085[source]
(Rejected) proposal to add something like this to the standard library gives some context: https://github.com/golang/go/issues/53171
3. chrchang523 ◴[] No.41881167[source]
The problem with cgo is the high function-call overhead; you only want to use it for fairly big chunks of work. Calling an assembly function from Go is a lot cheaper.

https://pkg.go.dev/github.com/grailbio/base/simd has some work I’ve done in this vein.

4. Andoryuuta ◴[] No.41881773[source]
I think people certainly have been trying for a while. In fact, I recall being on a (Skype?) call with my brother almost a decade ago while he was trying to write an SIMD library in Go. If I remember correctly, at that time, a bunch of the AVX instructions weren't even encodable in Go's Plan9 assembler - so we had to manually encode them as bytes [0].

The most complete library I've seen (though admittedly never used) uses CGO _partially_, with a neat hack to avoid the overhead that it comes with [1].

[0]: https://github.com/slimsag/rand/blob/f1e8d464c0021a391d5cd64...

[1]: https://github.com/alivanz/go-simd/