Skip to content

cmd/compile: large string constants being copied unnecessarily #15729

@SlyMarbo

Description

@SlyMarbo
  1. What version of Go are you using (go version)?
    • go/1.6
  2. What operating system and processor architecture are you using (go env)?
    • linux/amd64, darwin/amd64
  3. What did you do?
  4. What did you expect to see?
    • Compile size not to change noticeably after uncommenting the commented code.
  5. What did you see instead?
    • The binary size increased by len(data) bytes.

It appears that using a large string constant multiple times within a function results in that constant being copied into the compile binary multiple times. While this may be fine with small strings, it seems unnecessary with large strings and inflates the binary size and compile time significantly.

In the code in which this issue was discovered, the string constant was nearly 30 MB and resulted in the compile time increasing from ~6s to ~13s and the binary from ~27 MB to ~66 MB.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions