Skip to content

cmd/compile: big binary and slow compilation times with maps & []interface{} in static code #20095

Open
@philpennock

Description

@philpennock

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.1 darwin/amd64

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

darwin_amd64

What did you do?

I switched some static data from being encoded in the binary as a large raw string to generating Golang code representing data structures, where the data represented covers "all assigned Unicode codepoints", at 31618 elements.

I removed a couple of map[rune]whatever items and constructed them at runtime, to get compiler times down from one minute back to a couple of seconds.

Even after making that change, I did not initially notice that the unicode.a file had gone up to 509MB and the executable to 491MB. I tried a couple of things, but the key was to switch a slice of []interface{} to []ConcreteType. At runtime I need the []interface{} (to feed to Ferret for substring search) but switching the compiled-in slice from elements of interface{} to elements of concrete types brought unicode.a down to 4.4MB (from 509MB) and the executable down to 9.4MB.

Code is: https://github.com/philpennock/character
(go get compatible, though make will do some embedding)

What did you expect to see?

Non-degenerate performance in compile times or library/executable sizes.

What did you see instead?

Something which made me think I was compiling C++, not Golang. 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolSpeed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions