-
Notifications
You must be signed in to change notification settings - Fork 645
buildOnSave concurrency should be limited #1890
Comments
Thanks for bringing this up. Yes, we should pass the list of packages instead of calling
We can skip building the package when it does not correspond to the file that is open in the current active editor. PRs are very much welcome. |
@mgood If you are working on this, wait a few days till October starts before submitting the PR to win a t-shirt! See https://open.microsoft.com/2018/09/18/hacktoberfest-2018-microsoft/?WT.mc_id=hacktoberfest-twitter-beverst for more details |
Thanks, I haven't started on it, but I'll keep that in mind. |
Instead of running go build for each package in workspace, add all packages directly to it. Closes #1890
The fix to this bug is now available in the latest update to the Go extension (0.7.0) |
vscode-go version: 0.6.88
VSCode recently brought my system to a crawl after doing a find/replace that affected a number of files in a large Go project.
When I was able to get my terminal to respond I found a large number of process running like:
I had not changed
go.buildOnSave
, so it would have used the default ofpackage
. It appears that since I had saved files from a number of packages simultaneously, this triggered a large number of calls to build those packages which were all running at the same time.Looking at the code there seem to be two code paths in
goBuild
that would be affected by this in slightly different ways. WhenbuildWorkspace
is true it appears to scan for all packages and then launch thego
tool in parallel for all of them. Otherwise for thepackage
case it still appears thatgoBuild
can be called many times concurrently for each file that was saved, leading to a large number of runninggo
processes.On my system this caused the
go
processes to use all the available memory. Since they were constantly swapping and competing for resources it took a long time for the system to complete any of the builds.The process of building the workspace also appears like it will be doing redundant work by invoking
go build
separately for each package. Typically Go could analyze the package tree to only compile each package once, but by calling it in separate commands this could lead to Go rebuilding dependencies that are shared amongst other packages. Thego build
command can take a list of packages, so it seems like this should pass all the packages to one invocation ofgo build
.The text was updated successfully, but these errors were encountered: