Skip to content

Add //go:noescape to runtime_cgocall to eliminate per-call allocation #54

@unxed

Description

@unxed

While profiling goffi's performance, I noticed that it consistently makes 1 allocation per FFI call.

This occurs in internal/syscall/syscall_unix_*.go because runtime_cgocall is imported via //go:linkname but lacks the //go:noescape compiler directive. Because of this, the local args := syscallArgs{...} struct escapes to the heap every time CallNFloat is executed.

Adding //go:noescape directly above the runtime_cgocall declarations across architecture implementations will prevent this escape and achieve true zero-allocation FFI calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions