Skip to content

x/tools/cmd/stringer: stringer should not use go/types #25650

@robpike

Description

@robpike

It takes much longer to run stringer on a program than to compile it. Stringer should be nearly instantaneous, but I suspect the new importer technology is killing performance. Something certainly is.

At tip, wiith a freshly written file, so the build cache has the dependencies but not the output of building list.go itself:

% go version
go version devel +47be3d49c7 Thu May 10 23:19:40 2018 +0000 darwin/amd64
% cat list.go
package main

import (
	"gopkg.in/src-d/go-license-detector.v2/licensedb/filer"
)

func main() {
}

type Type int

const (
	Other Type = iota
	A
	B
	C
	D
)

func getFiler(file string) filer.Filer {
	return nil
}
% time go build

real	0m1.617s
user	0m1.290s
sys	0m0.408s
% time stringer -type Type

real	0m4.197s
user	0m2.409s
sys	0m0.782s
%

Stringer is taking almost 3 times as long to run as it takes to compile and link the binary. That's crazy. If we remove the dependency on filer, which has a pretty big set of dependencies itself, stringer runs quickly again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Performance

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions