Skip to content

Rust baseline compiled assembly difference #6

@rpjohnst

Description

@rpjohnst

From the README:

(It's not entirely clear why the Zig baseline implementation is twice as fast as the Rust implementation. The compiled assembly (godbolt) show that Rust saves five registers on the stack while Zig only saves three, but why? For the purpose of this benchmark it shouldn't matter since we're only comparing against the baseline of each language.)

The difference is that the linked Zig program produces an internal LLVM function, which can call itself directly, while the Rust program produces a non-internal LLVM function, which calls itself through the GOT. If you mark the Rust function non-pub and call it from a pub function (like the Zig main), you will get essentially the same assembly: https://godbolt.org/z/x73v9zKb9

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions