Skip to content

cmd/link: memory reductions slowed down the linker #31898

@aclements

Description

@aclements

CL 173938, which switched to using mmap'd symbol name strings, made the linker 15% slower. Based on the profile, the reason appears to be completely silly: the new call to r.rd.Offset() in objReader.readSymName is remarkably expensive. The Seek call used to find the offset is roughly 20% of the profile.

@cherrymui suggested we could make bio.Reader directly use the mmap'ed backing store when we have it and simply track its own offset. We should also avoid the Offset call if we don't have the mmap'ed backing store, since we don't need it then.

Alternatively, we could continue using the underlying file, but track the offset ourselves in bio.Reader.

/cc @thanm @cherrymui

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions