←back to thread

Show HN: Go Plan9 Memo

(pehringer.info)
302 points pehringer | 2 comments | | HN request time: 0s | 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.
Show context
saclark11 ◴[] No.41880371[source]
> Overall, pretty weird stuff. I am not sure why the Go team went down this route. Maybe it simplifies the compiler by having this bespoke assembly format?

Rob Pike spoke on the design of Go's assembler at a talk in 2016 [1][2]. I think it basically came down to the observation that most assembly language is roughly the same, so why not build a common assembly language that "lets you talk to the machine at the lowest level and yet not have to learn a new syntax." It also enables them to automatically generate a working assembler given an instruction manual PDF for a new architecture as input.

[1]: https://www.youtube.com/watch?v=KINIAgRpkDA [2]: https://go.dev/talks/2016/asm.slide#1

replies(4): >>41880468 #>>41881654 #>>41884035 #>>41886094 #
alphazard ◴[] No.41880468[source]
And it worked. Go established cross-compilation as table-stakes for new programming languages, at a time when very few were doing it well, if at all.
replies(5): >>41880634 #>>41880798 #>>41883225 #>>41883804 #>>41884968 #
cloudfudge ◴[] No.41880798[source]
Yes, this is a great leap forward in my opinion. I had to do a project at a previous job where I wrote an agent that ran on x86, MIPS and ARM, and doing it in Go was a no-brainer. The other teams who had a bunch of C code that was a nightmare to cross-compile were so jealous they eventually moved a lot of things to Go.

I've been doing this for 35 years and cross compiling anything nontrivial was always a toolchain nightmare. Discovering a world where all I had to do was set GOARCH=mips64 (and possibly GOOS=darwin if I wanted mac binaries) before invoking the compiler is so magical I was extremely skeptical when I first read about it.

replies(4): >>41881898 #>>41882917 #>>41883141 #>>41886387 #
bombela ◴[] No.41881898{3}[source]
As long as you don't have C libraries to cross compile / link against of course ;)
replies(1): >>41882993 #
akira2501 ◴[] No.41882993{4}[source]
sqlite is the only thing that makes me sad I have CGO_ENABLED=0.
replies(1): >>41883963 #
1. thombles ◴[] No.41883963{5}[source]
This non-cgo port might help - I started using it recently and it's fine but I'm not exactly a demanding user https://pkg.go.dev/modernc.org/sqlite
replies(1): >>41884507 #
2. KyleSanderson ◴[] No.41884507[source]
It's still pretty slow, but overall correct. There's tricks, like reader connections and a single writer connection to reduce contention. There was a blog post on here detailing some speedups in general.