-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: module graph pruning and lazy module loading #36460
Comments
Change https://golang.org/cl/217557 mentions this issue: |
Change https://golang.org/cl/220080 mentions this issue: |
A detailed design is in CL 220080. (You can view the rendered Markdown by opening the |
👍 I think that is a nice property to have. I have some projects for which |
I added a few examples (in our usual @ChrisHines, the third example explicitly covers the behavior for test-of-test dependencies. |
CC @julieqiu since this may affect how we display dependencies on CC @heschik, @dmitshur because this may affect the package search algorithms used by CC @bep because I seem to recall that Hugo is doing something unusual with module dependencies independent of Go package imports. (But note that we are unlikely to actively support the use of Go modules for purposes other than compiling Go source code.) |
Our unusual usage is fairly well anchored in the "Go project". That said, I have read your design document twice, and I think this is a good thing (even for our unusual use) -- but it would be easier to determine with a prototype (I find this topic to be a little bit of a mind twister and I don't fully understand the examples in the document). |
…ild tags I've been thinking about the relationship between the package import graph and the module import graph, and realized that the package import graph is not always acyclic. (The package import graph must be acyclic given a specific set of build tags, but the 'mod' subcommands intentionally ignore build tags.) I'm not sure whether we have any existing regression tests that cover this sort of cycle, so I'm adding one now. Thankfully, it passes! Updates #36460 Change-Id: I7679320994ee169855241efa51cd45f71315f7f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/217557 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
@bcmills This is excellent, thank you. I think I follow the detail, but have a couple of questions which might well prove otherwise 😄
I'm not sure what this sentence means. In the context of changing the definition of the Again related to the proposed change in the definition of the What about Regarding the transition to use the new behaviour. People will, per your proposal, need to specify Thinking about the compatibility section and CI use, if I've understood things correctly, running |
Not really, no: the But not that the |
Don't do that? 😅
I would argue that there weren't any situations where that was ever required (or particularly desirable). But if you have specific examples, I'd like to look into them in more depth. |
Currently the only other effect on module-mode semantics is that the transition from |
The difference between 1.13 and 1.14 is that 1.14 will not demolish those invariants unless you invoke Note that we have fixed bugs in |
This was the comment I had in mind when asking: which refers through to #27899. I've not followed that in detail, so just raising for completeness; the point may now be moot. |
Very much a tangent, but are these changes documented somewhere centrally? That would be an incredibly useful guide to start and maintain (vs having the details scattered in various parts of the docs). |
Ah, now I remember. The untidiness there was “larger than tidy” rather than “smaller than tidy”, and I think we have basically settled on the |
Not yet. That's arguably part of #30791... |
The /doc link is currently a redirect (CL 334389), but I plan to update it soon with a more detailed guide. Updates #36460 Change-Id: I9e4a47ad0c8bcb7361cfa3e5b9d07ad241b13ba6 Reviewed-on: https://go-review.googlesource.com/c/go/+/332573 Trust: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
Change https://golang.org/cl/334889 mentions this issue: |
I neglected to run the 'longtest' builder, and the tests that cover the error message changed in CL 332573 apparently do not run in short mode. Updates #36460 Updates #42661 Change-Id: I53500ddaca8ac9f0dfaab538923b3c9a4f71665e Reviewed-on: https://go-review.googlesource.com/c/go/+/334889 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]>
Change https://golang.org/cl/335135 mentions this issue: |
For golang/go#36460 Change-Id: I36b3657103f069412b225356d011a19c1a10109e Reviewed-on: https://go-review.googlesource.com/c/website/+/333629 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
Change https://golang.org/cl/345391 mentions this issue: |
Change https://golang.org/cl/345393 mentions this issue: |
Updates #36460 Change-Id: I19f375f58f118e83a2615a29bbbb3853f059f0bb Reviewed-on: https://go-review.googlesource.com/c/go/+/345391 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
…runed module graphs The level of support for pruning — not the lazy/eager loading behavior — is the more fundamental property, and what matters in terms of what invariants we need to maintain. If the main module supports pruned module graphs we load its dependencies lazily, and if it does not support pruned module graphs we load its dependencies eagerly. However, in principle we could also load the module graph lazily even in modules that do not support graph pruning — we would just be more likely to overlook inconsistent requirements introduced by hand-edits or bad VCS merges to the go.mod file. (After this change, a “lazy” module is just one in which we happen not to have loaded the module graph, and an “eager” one is one in which we happen to load the module graph more aggressively.) Updates #36460 For #47397 Change-Id: I0d2ffd21acc913f72ff56b59a6bdc539ebc3d377 Reviewed-on: https://go-review.googlesource.com/c/go/+/345393 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
This change was produced using 'go mod tidy -go=1.17' with a go command built at CL 315210. This activates lazy loading, and updates the go.mod file to maintain the lazy-loading invariants (namely, including an explicit requirement for every package transitively imported by the main module). Note that this does *not* prevent users with earlier go versions from successfully building packages from this module. For golang/go#36460. Change-Id: I6697dd2fd740e59b959ee7b0458227374915293e Reviewed-on: https://go-review.googlesource.com/c/xerrors/+/316114 Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
This change was produced using 'go mod tidy -go=1.17' with a go command built at CL 315210. This activates lazy loading, and updates the go.mod file to maintain the lazy-loading invariants (namely, including an explicit requirement for every package transitively imported by the main module). Note that this does *not* prevent users with earlier go versions from successfully building packages from this module. For golang/go#36460 Change-Id: Iabb65fc3ed9727abecc3926abcecd445c967d0a9 Reviewed-on: https://go-review.googlesource.com/c/text/+/315571 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
…ing dependencies” I plan to add a more in-depth troubleshooting guide at this URL. For now, I just need to URL to work so that I can point to it in the 'go' command in Go 1.17 (in CL 332573). For golang/go#36460 Change-Id: I95f03f76519dfb196ed6c9c13003b2ad9becf6c9 Reviewed-on: https://go-review.googlesource.com/c/website/+/334389 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Steve Traut <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
For golang/go#36460 Change-Id: I36b3657103f069412b225356d011a19c1a10109e Reviewed-on: https://go-review.googlesource.com/c/website/+/333629 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
This change was produced using 'go mod tidy -go=1.17' with a go command built at CL 315210. This activates lazy loading, and updates the go.mod file to maintain the lazy-loading invariants (namely, including an explicit requirement for every package transitively imported by the main module). Note that this does *not* prevent users with earlier go versions from successfully building packages from this module. For golang/go#36460. Change-Id: I28a6f54b1e41e9e18b726cacba25a52069b8a4e9 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/316109 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]> TryBot-Result: Go Bot <[email protected]>
This change was produced using 'go mod tidy -go=1.17' with a go command built at CL 315210. This activates lazy loading, and updates the go.mod file to maintain the lazy-loading invariants (namely, including an explicit requirement for every package transitively imported by the main module). Note that this does *not* prevent users with earlier go versions from successfully building packages from this module. For golang/go#36460. Change-Id: Idb3d8d056d41bb254d0b5d9b2699ac33a51081f3 Reviewed-on: https://go-review.googlesource.com/c/sync/+/316130 Auto-Submit: Bryan Mills <[email protected]> Commit-Queue: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
I propose to change
cmd/go
to avoid loading transitive module dependenciesthat have no observable effect on the packages to be built.
The key insights that lead to this approach are:
If no package in a given dependency module is ever (even transitively)
imported by any package loaded by an invocation of the
go
command, then anincompatibility between any package in that dependency and any other package
has no observable effect in the resulting program(s). Therefore, we can
safely ignore the (transitive) requirements of any module that does not
contribute any package to the build.
We can use the explicit requirements of the main module as a coarse filter
on the set of modules relevant to the main module and to previous
invocations of the
go
command.Based on those insights, I propose to change the
go
command to retain moretransitive dependencies in
go.mod
files and to avoid loadinggo.mod
filesfor “irrelevant” modules, while still maintaining high reproducibility for build
and test operations.
Design doc: http://golang.org/design/36460-lazy-module-loading.
The text was updated successfully, but these errors were encountered: