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

go/packages: allow types loading without NeedDeps #139

Closed
wants to merge 3 commits into from

Conversation

jirfag
Copy link
Contributor

@jirfag jirfag commented Jul 16, 2019

Before separating Load* into Need* we could use LoadSyntax
to get types information by loading inital packages
from source code and loading it's direct dependencies from export data.
It was broken when separation was introduced and before this commit
everything was loading from source code what resulted into slow
loading times. This commit fixes it.

Also, do backwards-incompatible fix of definition of deprecated
LoadImports and LoadAllSyntax.

Improve an internal error message
"internal error: nil Pkg importing x from y": replace it with
"internal error: package x without types was imported from y".

Remove packages.NeedDeps request for loading in tests
TestLoadTypesBits and TestContainsOverlayXTest.

Fixes golang/go#31752, fixes golang/go#33077, fixes golang/go#32814,
fixes golang/go#31699, fixes golang/go#31930

@gopherbot
Copy link
Contributor

This PR (HEAD: 2a85316) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
Within the next week or so, a maintainer will review your change and provide
feedback. See https://golang.org/doc/contribute.html#review for more info and
tips to get your patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11, it means that this CL will be reviewed as part of the next development
cycle. See https://golang.org/s/release for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@jirfag
Copy link
Contributor Author

jirfag commented Jul 16, 2019

Looks like it fixes golang/go#31699 too,
and has conflicting code with golang/go#32814

/cc @matloob

@codeactual
Copy link

Thanks for this PR.

It also fixes golang/go#31930.

Now seeing run times and alloc_space profiles cut about in half for my use case, allowing me to query for types info and LoadSyntax but w/o the mandatory LoadSyntaxAll cost of parsing standard libraries, etc. that were not the target of the Load query.

@jirfag jirfag force-pushed the master branch 2 times, most recently from 3ae24b8 to 979bdb7 Compare September 9, 2019 10:42
@gopherbot
Copy link
Contributor

This PR (HEAD: 3ae24b8) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

This PR (HEAD: 979bdb7) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@jirfag
Copy link
Contributor Author

jirfag commented Sep 9, 2019

I've resolved merge conflicts.
@matloob @ianthehat @stamblerre please, take a look on it. This pull request fixes 5 issues about serious performance regression after splitting Load* into more fine-grained Need*.

jirfag added a commit to golangci/golangci-lint that referenced this pull request Sep 9, 2019
@gopherbot
Copy link
Contributor

Message from Michael Matloob:

Patch Set 3:

(2 comments)

I agree we should fix the issue where we load everything from source, even if the user doesn't need it, but I don't want to change the meaning of the NeedX fields.

Here's my idea to fix this (which I think should require minimal changes to your CL): Have the loader keep a separate set of "implied" NeedX bits, called, say, "impliedMode". Then addDependingLoadModes can set impliedMode instead of modifying ld.Mode directly. Because the loader keeps the original mode, it can then clear the bits the same way it was doing before this change.

What do you think?


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

Before separating Load* into Need* we could use LoadSyntax
to get types information by loading inital packages
from source code and loading it's direct dependencies from export data.
It was broken when separation was introduced and before this commit
everything was loading from source code what resulted into slow
loading times. This commit fixes it.

Also, do backwards-incompatible fix of definition of deprecated
LoadImports and LoadAllSyntax.

Improve an internal error message
"internal error: nil Pkg importing x from y": replace it with
"internal error: package x without types was imported from y".

Remove packages.NeedDeps request for loading in tests
TestLoadTypesBits and TestContainsOverlayXTest.

Fixes golang/go#31752, fixes golang/go#33077, fixes golang/go#32814,
      fixes golang/go#31699, fixes golang/go#31930
@gopherbot
Copy link
Contributor

This PR (HEAD: 08e470e) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

Save the actually requested fields in loader.requestedMode.
loader.Mode contains the implied mode (see implyLoadMode):
  all the fields we need the data for.
Zero out unrequested fields before returning packages to the user
  by checking loader.requestedMode.
@gopherbot
Copy link
Contributor

This PR (HEAD: 3540c02) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Denis Isaev:

Patch Set 5:

Thank you for your comments! I've removed information about implied modes from Need* comments. And I've created requestedMode to save actually requested mode. Adding impliedMode will be much more difficult because:
a. We need to change the interface of drivers: goListDriver accepts Config as an argument and uses Mode from it. Or we need to add local field impliedMode into Config: I think it will add complexity for users of go/packages.
b. We need to change ~40 places in code Mode -> impliedMode.
c. It will be easy to use Mode instead of impliedMode: cost of supporting will be higher.


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Matloob:

Patch Set 5:

(2 comments)

Patch Set 5:

Thank you for your comments! I've removed information about implied modes from Need* comments. And I've created requestedMode to save actually requested mode. Adding impliedMode will be much more difficult because:
a. We need to change the interface of drivers: goListDriver accepts Config as an argument and uses Mode from it. Or we need to add local field impliedMode into Config: I think it will add complexity for users of go/packages.
b. We need to change ~40 places in code Mode -> impliedMode.
c. It will be easy to use Mode instead of impliedMode: cost of supporting will be higher.

Sounds good! just a couple of comments about the impliedMode function


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Matloob:

Patch Set 5:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: f015199) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Denis Isaev:

Patch Set 6:

(3 comments)

thank you for the review, I've fixed all comments, but it required me to do a lot of changes.


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Matloob:

Patch Set 6:

(1 comment)

Hi, sorry this review is taking so long.

Could you revert the changes you made in your most recent patch set (except for making impliedMode a function)? I'll submit that change and we can work on the rest in a separate review.


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 2e3a46e) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/186337 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Denis Isaev:

Patch Set 6:

ok, I've reverted the last change and left only impliedLoadMode function refactoring. Please, take a look at it again.


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Matloob:

Patch Set 7: Code-Review+2

(1 comment)

one more small thing


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Denis Isaev:

Patch Set 7:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/186337.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Sep 11, 2019
Before separating Load* into Need* we could use LoadSyntax
to get types information by loading inital packages
from source code and loading it's direct dependencies from export data.
It was broken when separation was introduced and before this commit
everything was loading from source code what resulted into slow
loading times. This commit fixes it.

Also, do backwards-incompatible fix of definition of deprecated
LoadImports and LoadAllSyntax.

Improve an internal error message
"internal error: nil Pkg importing x from y": replace it with
"internal error: package x without types was imported from y".

Remove packages.NeedDeps request for loading in tests
TestLoadTypesBits and TestContainsOverlayXTest.

Fixes golang/go#31752, fixes golang/go#33077, fixes golang/go#32814,
          fixes golang/go#31699, fixes golang/go#31930

Change-Id: I416e3c1035d555d67039e45a4fdd1deb9b2184ef
GitHub-Last-Rev: 2e3a46e
GitHub-Pull-Request: #139
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186337
Reviewed-by: Michael Matloob <matloob@golang.org>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/186337 has been merged.

@gopherbot gopherbot closed this Sep 11, 2019
jirfag pushed a commit to golangci/golangci-lint that referenced this pull request Sep 14, 2019
* Update to ultraware/funlen v0.0.2.

Fixes ultraware/funlen#1.

* Update to latest golang.org/x/tools.

Fixes #687.
Fixes golang/tools#139.
clintjedwards pushed a commit to clintjedwards/tools that referenced this pull request Sep 19, 2019
Before separating Load* into Need* we could use LoadSyntax
to get types information by loading inital packages
from source code and loading it's direct dependencies from export data.
It was broken when separation was introduced and before this commit
everything was loading from source code what resulted into slow
loading times. This commit fixes it.

Also, do backwards-incompatible fix of definition of deprecated
LoadImports and LoadAllSyntax.

Improve an internal error message
"internal error: nil Pkg importing x from y": replace it with
"internal error: package x without types was imported from y".

Remove packages.NeedDeps request for loading in tests
TestLoadTypesBits and TestContainsOverlayXTest.

Fixes golang/go#31752, fixes golang/go#33077, fixes golang/go#32814,
          fixes golang/go#31699, fixes golang/go#31930

Change-Id: I416e3c1035d555d67039e45a4fdd1deb9b2184ef
GitHub-Last-Rev: 2e3a46e
GitHub-Pull-Request: golang#139
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186337
Reviewed-by: Michael Matloob <matloob@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment