Skip to content
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

:GoBuild is slower than expected when rebuilding binaries #2245

Open
kevinburke opened this issue Apr 27, 2019 · 7 comments
Open

:GoBuild is slower than expected when rebuilding binaries #2245

kevinburke opened this issue Apr 27, 2019 · 7 comments

Comments

@kevinburke
Copy link

If I compile a file that has no changes to the file contents or dependencies using :GoBuild, I would expect it to take advantage of the build cache from the last time it compiled. Instead, vim-go issues go build -tags '' . errors from the directory of the file I am attempting to compile. This command never takes advantage of the build cache - it takes 4 seconds for the package I am trying to compile.

By contrast, :GoInstall does take advantage of the build cache. It seems like it is strictly better to use than :GoBuild. Even if you replaced :GoBuild with :GoInstall followed by rm -rf of the created artifacts, it seems like it would be faster than "go build."

@bhcleek
Copy link
Collaborator

bhcleek commented Apr 27, 2019

vim-go purposefully builds the package of the current file and the errors package so that a build result file won't be produced. From http://golang.org/cmd/go:

When compiling multiple packages or a single non-main package, build compiles the packages but discards the resulting object, serving only as a check that the packages can be built.

:GoInstall's approach isn't a viable solution for vim-go, because it's not known where the file might be installed to or whether it is safe to delete afterwards.

It might be possible to build to /dev/null on *nix and NUL on Windows, though, so that multiple packages don't have to be passed to get go build to not produce a file.

@kevinburke
Copy link
Author

I guess I'm not so much worried about that as I am about it being a fast operation... is there no way to get go build to be fast without producing an artifact?

My understanding was each library builds a .a file and it seems like checking those intermediate results should be fast even if no artifact is actually built...

@bhcleek
Copy link
Collaborator

bhcleek commented Apr 27, 2019

That's not a decision that's up to vim-go. I agree that it would be optimal. Have you checked to see whether there's an issue for this on github.com/golang/go?

@kevinburke
Copy link
Author

Filed golang/go#31710.

@bhcleek bhcleek changed the title :GoBuild is slow, never uses cache :GoBuild is slower than expected when rebuilding binaries Apr 28, 2019
@bhcleek
Copy link
Collaborator

bhcleek commented Apr 28, 2019

I experimented with using go build -o /dev/null . instead of go build . errors, but there was no performance improvement. Some further experimentation shows that the performance lag you're referring to only happens when building binaries; rebuilding library packages is fast as-is and seems to re-use the cache.

I don't think there's anything we can do to improve the situation, but I'm open to ideas or any data that shows that my assessment is wrong.

@bhcleek
Copy link
Collaborator

bhcleek commented Apr 30, 2019

Given that there's a Go issue for this now, I'm going to leave this open so that we can track the linked Go issue and improve vim-go if/when the enhancement is made in Go.

@genuiner
Copy link

genuiner commented Apr 5, 2023

when i use GoRun, sometimes vim did not respond and began hang, in this situation, i had to kill vim process and reopen a new vim process, what is the problem.

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

No branches or pull requests

3 participants