petermattis / goid

Apache License 2.0
442 stars 65 forks source link

Merge go1.5+ assembly #32

Closed tamird closed 1 year ago

tamird commented 1 year ago

See commit message.

tamird commented 1 year ago

The goal was just to reduce the mental overhead of reading this code. Regarding the added function call: I see no difference on local benchmarks:

Before:

$ go test -v -bench .
=== RUN   TestGet
--- PASS: TestGet (0.00s)
goos: linux
goarch: amd64
pkg: github.com/petermattis/goid
cpu: AMD Ryzen 9 7950X 16-Core Processor            
BenchmarkGet
BenchmarkGet-32         1000000000               0.9726 ns/op
PASS
ok      github.com/petermattis/goid     1.073s

After:

$ go test -v -bench .
=== RUN   TestGet
--- PASS: TestGet (0.00s)
goos: linux
goarch: amd64
pkg: github.com/petermattis/goid
cpu: AMD Ryzen 9 7950X 16-Core Processor            
BenchmarkGet
BenchmarkGet-32         1000000000               0.9563 ns/op
PASS
ok      github.com/petermattis/goid     1.076s

I suspect that's because Get itself is always inlined, so the only real function call is into getg.

tamird commented 1 year ago

Added CI coverage for inlining as well.