Skip to content

cmd/gc: superlinear slow-down compiling slice of interface literal #8354

Closed
@bradfitz

Description

@bradfitz
As the number of elements in a slice of interface literal grows, cmd/gc slows down more
than linearly:

http://play.golang.org/p/5TDTCtaP3Q


package main

type I interface {
    foo()
}

type S string

func (S) foo() {}

var s = []I{
    S("foo"),
    S("foo"),
    S("foo"),
    S("foo"),
    S("foo"),
    S("foo"),
    S("foo"),
    S("foo"),
    S("foo"),
...


Observed times for "go build x.go":

  100   0.003s
 1000   0.187s
 2000   0.784s
 3000   1.593s
 4000   2.655s
 5000   4.016s
 6000   5.685s
 7000   7.600s
14000   29.234s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions