Skip to content

replace @setCold with @cold #5177

Closed as not planned
Closed as not planned
@andrewrk

Description

@andrewrk

Status quo:

@setCold(is_cold: bool) void

Tells the optimizer that a function is rarely called.

Proposal:

@cold() void

Annotates that it is relatively uncommon for control flow to reach this point. Similar to unreachable, but only communicates probability. It communicates a willingness to compromise performance of the cold path in order to improve performance of the hot path.

This makes #489 unnecessary. Instead of:

if (@expect(foo, true)) {
   bar();
} else {
   baz();
}

With this proposal:

if (foo) {
    bar();
} else {
    @cold();
    baz();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions