Skip to content

"typecheck" takes ~5 times longer than "go build" #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alecthomas opened this issue Jun 1, 2018 · 4 comments
Closed

"typecheck" takes ~5 times longer than "go build" #54

alecthomas opened this issue Jun 1, 2018 · 4 comments

Comments

@alecthomas
Copy link
Contributor

$ time golangci-lint run --disable-all --enable typecheck
Congrats! No issues were found.
golangci-lint run --disable-all --enable typecheck  4.61s user 1.51s system 391% cpu 1.562 total
$ time go build .
go build .  0.72s user 0.50s system 139% cpu 0.873 total
@golangci
Copy link
Collaborator

golangci commented Jun 2, 2018

hi!

  1. run with -v please
  2. can you compare it with another linters? gometalinter, errcheck? It should not be slower.

Typecheck works fast, but program loader is slow. I have plans to improve its speed by caching and reusing compilation cache.

@alecthomas
Copy link
Contributor Author

$ time golangci-lint -v run --disable-all --enable typecheck
INFO[0000] Concurrency: 8, machine cpus count: 8
INFO[0000] Active linters: [typecheck]
INFO[0000] set GOROOT="/usr/local/Cellar/go/1.10.2/libexec"
INFO[0000] Found paths for analysis for 201.447µs: [.]
INFO[0001] Program loading took 1.462691677s
INFO[0001] worker.6 took 4.96µs with stages: typecheck: 803ns
INFO[0001] worker.5 took 2.21µs
INFO[0001] worker.4 took 913ns
INFO[0001] worker.3 took 945ns
INFO[0001] worker.7 took 10.953µs
INFO[0001] worker.2 took 9.82µs
INFO[0001] worker.8 took 12.754µs
INFO[0001] worker.1 took 47.418µs
INFO[0001] Workers idle times: #2: 76.443µs, #3: 85.506µs, #4: 132.962µs, #5: 146.895µs, #6: 154.698µs, #7: 83.501µs, #8: 48.761µs
INFO[0001] processing took 15.629µs with stages: max_same_issues: 14.396µs, path_prettifier: 331ns, max_from_linter: 204ns, exclude: 200ns, cgo: 173ns, nolint: 130ns, max_per_file_from_linter: 116ns, uniq_by_line: 42ns, diff: 37ns
Congrats! No issues were found.
INFO[0001] Extracting issued lines took 0s
INFO[0001] Memory: 15 samples, avg is 188.9MB, max is 244.5MB
INFO[0001] Execution took 1.486011496s
golangci-lint -v run --disable-all --enable typecheck  4.48s user 1.54s system 378% cpu 1.591 total

Yes, they are all slow. I'm guessing go build is fast because of the new build cache. It'd be great if golangci-lint could utilise the cache.

@jirfag
Copy link
Contributor

jirfag commented Jun 12, 2018

While investigating #87 (comment) I found that go build cache can be used to speed up loading. But it's not compatible with interfacer and megacheck: they build SSA representation and therefore need information about all functions of all dependencies. This information isn't stored in build cache.
Megacheck and interfacer are enabled at 80% of cases, it doesn't make sense to optimize 20%.

More perspective is to make incremental program loading to speedup 100% of not --fast analyzes. It will be done by #92.

@jirfag jirfag closed this as completed Jun 12, 2018
@alecthomas
Copy link
Contributor Author

Makes sense, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants