Skip to content

use frame pointer unwinding for Go 1.21+ on aarch64#422

Merged
fabled merged 2 commits intoopen-telemetry:mainfrom
fabled:golang-arm64-framepointer-unwind
Apr 17, 2025
Merged

use frame pointer unwinding for Go 1.21+ on aarch64#422
fabled merged 2 commits intoopen-telemetry:mainfrom
fabled:golang-arm64-framepointer-unwind

Conversation

@fabled
Copy link
Copy Markdown
Contributor

@fabled fabled commented Mar 31, 2025

Introduce a mechanism for native frame pointer unwinding in the ebpf code, and use it for the V8 and Golang unwinders. This allows a slightly optimized unwinding to happen as less bpf_probe_read_user() calls are done with the expense of slightly larger native unwinder ebpf program.

Enable frame pointer unwinding for Go1.21+ on aarch64 (this significantly reduces the kernel memory needed for Go executable stack delta maps).

fixes #342

@fabled fabled force-pushed the golang-arm64-framepointer-unwind branch from 0724bfe to f95662e Compare March 31, 2025 13:58
Comment thread support/ebpf/tracemgmt.h Outdated
Comment thread nativeunwind/elfunwindinfo/elfgopclntab.go Outdated
@fabled fabled force-pushed the golang-arm64-framepointer-unwind branch from c9ccd1f to 30fb123 Compare April 7, 2025 16:35
Introduce a mechanism for native frame pointer unwinding in
the ebpf code, and use it for the V8 and Golang unwinders.
This allows a slightly optimized unwinding to happen as less
bpf_probe_read_user() calls are done with the expense of
slightly larger native unwinder ebpf program.

Enable frame pointer unwinding for Go1.21+ on aarch64.

fixes open-telemetry#342
@fabled fabled force-pushed the golang-arm64-framepointer-unwind branch from 30fb123 to a3c7287 Compare April 7, 2025 16:36
@fabled fabled marked this pull request as ready for review April 7, 2025 16:56
@fabled fabled requested review from a team as code owners April 7, 2025 16:56
Copy link
Copy Markdown
Member

@christos68k christos68k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I can't test this atm.

Comment thread nativeunwind/elfunwindinfo/elfgopclntab.go Outdated
Copy link
Copy Markdown
Member

@florianl florianl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor comments, that can be addressed in a follow up. Besides that 👍 thanks for the update!

// Ambiguous regarding if frame pointer is kept correctly.
// Take the slow path of resolving Go version.
goVer, err := ee.file.GoVersion()
if err != nil || version.Compare(goVer, "go1.21rc1") < 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Release candidates are for temporary testing. Maybe we can just use the first release with this change in Go:

Suggested change
if err != nil || version.Compare(goVer, "go1.21rc1") < 0 {
if err != nil || version.Compare(goVer, "go1.21.0") < 0 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a strong preference to keep the actual first rc tag here. The Go libraries support comparing versions with them, and this makes the code work with the prerelease tags. This also serves as note to remind what is the first tag when the Golang change was made.

UnwindCommandStop int32 = C.UNWIND_COMMAND_STOP
UnwindCommandPLT int32 = C.UNWIND_COMMAND_PLT
UnwindCommandSignal int32 = C.UNWIND_COMMAND_SIGNAL
UnwindCommandInvalid int32 = C.UNWIND_COMMAND_INVALID
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should bring these constants into support/types_def.go - then we don't need to manually keep them in sync. But this can be part of another PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do a follow up PR on this.

@fabled fabled merged commit 85314fc into open-telemetry:main Apr 17, 2025
26 checks passed
florianl added a commit that referenced this pull request Apr 23, 2025
Reduce the spread of CGO across the code base and move definitions to support package.

Follow up to #422 (comment)

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
florianl added a commit that referenced this pull request Apr 23, 2025
Reduce the spread of CGO across the code base and move definitions to support package.

Follow up to #422 (comment).

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Golang arm64 native unwinder

3 participants