Skip to content

cmd/compile: deduplicate alg and noalg type descriptors to allow binary space optimizations #47904

Open
@martisch

Description

@martisch

The compiler supports SetNoAlg on types. This brings binary space savings by not needing to generate equality functions for those types. Applying this setting to backing arrays of slices (#32595) and maps (#47068) has introduced bugs into go binaries in the past because values of types that should be equal didnt compare equal as internally they were different types.

The general fix and even better space saving impact would be to have the compiler/linker deduplicate noalg with alg type descriptors giving preference to alg descriptors that link algorithms. See discussion with @mdempsky #47068 (comment)

Alternatively the compiler and linker combination could be smart enough to understand if algs can ever be used because the type is never exposed directly to user code. While this is more general and automatic, it would be more complex and require more work during compilation/linking instead of annotating the places where it is the case manually using SetNoAlg in the compiler.

Once this is ready we can save binary space by:

/cc @mdempsky @cherrymui @randall77

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.binary-sizecompiler/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