1
0
mirror of https://github.com/golang/go synced 2024-11-18 21:44:45 -07:00
go/cmd
Brad Fitzpatrick edf8e6fef8 cmd/goimports, imports: optimize directory scanning and other things
This brings goimports from 160ms to 100ms on my laptop, and under 50ms
on my Linux machine.

Using cmd/trace, I noticed that filepath.Walk is inherently slow.
See https://golang.org/issue/16399 for details.

Instead, this CL introduces a new (private) filepath.Walk
implementation, optimized for speed and avoiding unnecessary work.

In addition to avoid an Lstat per file, it also reads directories
concurrently. The old goimports code did that too, but now that logic
is removed from goimports and the code is simplified.

This also adds some profiling command line flags to goimports that I
found useful.

Updates golang/go#16367 (goimports is slow)
Updates golang/go#16399 (filepath.Walk is slow)

Change-Id: I708d570cbaad3fa9ad75a12054f5a932ee159b84
Reviewed-on: https://go-review.googlesource.com/25001
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-19 03:21:45 +00:00
..
benchcmp benchmark/parser, cmd/benchcmp: improve names of exported identifiers 2015-01-15 01:28:17 +00:00
bundle cmd/bundle: move down imports of external package 2016-05-26 02:53:53 +00:00
callgraph x/tools/cmd/callgraph: add -ptalog flag 2015-12-04 17:49:28 +00:00
cover all: address vet issues, fix print calls 2016-03-27 20:36:34 +00:00
digraph tools: add import comments. 2014-12-09 22:42:16 +00:00
eg refactor/eg: refactor to break dependency on go/loader 2015-09-01 14:26:06 +00:00
fiximports cmd/fiximports: -replace flag specifies canonical packages in absence of import comments 2015-09-01 14:23:39 +00:00
godex x/tools: delete x/tools/go/types and dependent packages/client files 2016-04-06 21:52:49 +00:00
godoc cmd/godoc: set Strict-Transport-Security header in production 2016-05-02 17:22:30 +00:00
goimports cmd/goimports, imports: optimize directory scanning and other things 2016-07-19 03:21:45 +00:00
gomvpkg go/buildutil: TagsFlag provides a flag.Value for setting build.Context.BuildTags from -tags flag. 2015-04-23 14:10:21 +00:00
gorename cmd/gorename: -d flag prints diffs instead of rewriting files 2015-12-30 15:25:00 +00:00
gotype x/tools: delete x/tools/go/types and dependent packages/client files 2016-04-06 21:52:49 +00:00
guru cmd/guru: suppress failing test on plan9 2016-07-18 14:28:24 +00:00
html2article tools: fix 'Split called after Scan' 2016-05-04 16:29:22 +00:00
oracle cmd/oracle: announce planned deletion in 2.5 months 2016-07-18 23:21:13 +00:00
present x/tools/cmd/present: Fix present not working on Safari 2016-07-03 04:58:21 +00:00
ssadump x/tools: delete x/tools/go/types and dependent packages/client files 2016-04-06 21:52:49 +00:00
stress all: fix plan9 failures 2016-01-28 00:31:03 +00:00
stringer cmd/stringer: fixed usage line typo 2016-04-17 02:19:27 +00:00
tip tip: update package doc to refer to stable code 2016-07-11 22:47:40 +00:00