Skip to content

cmd/compile: optimizing multiple accesses to same key in map #17133

Open
@rasky

Description

@rasky

I was reviewing some code for performance issues, and the profile pointed me to a function that was accessing the same map element multiple times like this:

data[key].Foo = 1
data[key].Bar.Baz += 4
[...]

The profile showed many calls to runtime.mapaccess1_fast32. I was wondering if it would be legal for the compiler to optimize this straight code to do only one map access, and then of course if it's worth doing it or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions