-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
unused: significant performance and memory usage regression between 2017.2.2 and 2019.1 #394
Comments
This is with go1.11.4 by the way. Looks like the increased memory usage happened with commit a85e435. |
Unfortunately that is kind of to be expected. go/packages changes the way tests and their dependencies are handled. Tests require their own versions of dependencies (including the package under test). The old go/loader didn't do this, instead bundling both packages in one. The new go/packages works correctly. Unfortunately the consequence is that we're dealing with approximately twice the number of packages. There are of course ways to improve unused's memory usage, and to deduplicate data from both packages, but that'll require some design changes in unused. And unused, right now, is a hot mess, being one of my first tool projects. It is due for a rewrite, but that rewrite is too far in the future to be a solution to these issues. I'll see what I can do in the short-term. In the meantime, you can experiment with setting GOGC to a value lower than 100, to force more frequent GCs, which keeps the overall heap smaller, at the cost of increased CPU usage. I will also push a change that disables running |
That is an unfortunate lie, considering the C dependencies, some of which seems to be bundled with cockroach and not available in package managers (at least I assume that |
Hm, you are right, sorry. You would need to first run But anyway sounds like there is likely nothing special about the repo. I will experiment with GOGC. |
Do note that a large part of
Normal operation does suffer from the same >2x increase, and we do have to fix that, but a temporary workaround would be to forego whole program mode, assuming the other changes in staticcheck 2019.1 are worth that compromise. |
Thanks, yeah I did notice that without |
types.Implements is a relatively expensive operation, producing a lot of garbage in lookupFieldOrMethod. When I tested 2019.1 on github.com/cockroachdb/cockroach/pkg/..., lookupFieldOrMethod allocated 23 GB of garbage. Updates gh-394
The standard types.Implements implementation produces a lot of garbage in lookupFieldOrMethod. By using MethodSetCache and method sets, we can avoid a lot of this garbage. This directly translates to lower runtimes and lower peak memory usage. Compared with 442643a, for std and cockroachdb, we get the following numbers: Total allocations std: 6268 MB -> 4702 MB cdb: 28398 MB -> 19048 MB Peak rss std: 4,556,404 -> 3,253,004 cdb: 17,403,616 -> 12,546,948 Time std: 0:25.18 -> 0:21.84 cdb: 1:45.70 -> 1:30.74 Updates gh-394
types.Implements is a relatively expensive operation, producing a lot of garbage in lookupFieldOrMethod. When I tested 2019.1 on github.com/cockroachdb/cockroach/pkg/..., lookupFieldOrMethod allocated 23 GB of garbage. Updates gh-394
The standard types.Implements implementation produces a lot of garbage in lookupFieldOrMethod. By using MethodSetCache and method sets, we can avoid a lot of this garbage. This directly translates to lower runtimes and lower peak memory usage. Compared with 442643a, for std and cockroachdb, we get the following numbers: Total allocations std: 6268 MB -> 4702 MB cdb: 28398 MB -> 19048 MB Peak rss std: 4,556,404 -> 3,253,004 cdb: 17,403,616 -> 12,546,948 Time std: 0:25.18 -> 0:21.84 cdb: 1:45.70 -> 1:30.74 Updates gh-394
I'm going to merge this issue into #376. Once we finish the port, memory usage will be greatly reduced. |
For the CockroachDB repo, unused in 2017.2.2 used to take ~30s and use ~8GB RAM. In 2019.1 it takes ~100 seconds and over 16GB RAM. The memory usage is especially concerning because on systems with 16GB, it will swap and become terribly slow.
Below are some stats with
/usr/bin/time -v
between the two versions. This should be easily reproducible by just pulling the cockroach repo.The text was updated successfully, but these errors were encountered: