Skip to content

x/tools/go/types/objectpath: frequent use of scope.Names burns significant cycles #51017

@amscanne

Description

@amscanne

What version of Go are you using (go version)?

go1.18-pre10

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

Linux, amd64. Not dependent on OS or architecture, however.

What did you do?

The objectpath.For method relies on frequent calls to scope.Names(), which always performs a sort of all names. For large-scale analysis trees, this can consume a significant portion of cycles (30-50% in my case) and can easily be memoized. This can either be done by objectpath as a consumer of the API, or within the *types.Scope object.

What did you expect to see?

Fewer cycles spent sorting.

What did you see instead?

Lots of cycles spent sorting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Performance

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions