Closed tamird closed 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
.
Added CI coverage for inlining as well.
See commit message.