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: should _go_external_package dependency inference move to target generation? #12928

Closed
Eric-Arellano opened this issue Sep 16, 2021 · 3 comments
Labels
backend: Go Go backend-related issues

Comments

@Eric-Arellano
Copy link
Contributor

Target generation opens up a new possibility: dynamically inferring deps at target generation time, rather than dependency resolution time. Would it make sense to do that?

I think this would imply that _go_external_package targets would only depend on other targets defined in the same go.mod, which maybe we want?

Possible pros to explore:

  • Can we run fewer processes for better performance?
  • ./pants peek is more interesting because it includes values in the dependencies field, whereas you'd otherwise have to use ./pants dependencies

A con is that manually declared _go_external_package targets are much less practical. Although we might not care about this.

@Eric-Arellano Eric-Arellano added the backend: Go Go backend-related issues label Sep 16, 2021
@Eric-Arellano
Copy link
Contributor Author

If we remove the -find arg from here:

json_result = await Get(
ProcessResult,
GoSdkProcess(
input_digest=downloaded_module.digest,
# "-find" skips determining dependencies and imports for each package.
command=("list", "-find", "-mod=readonly", "-json", "./..."),
env={"GOPROXY": "off"},
description=(
"Determine packages belonging to Go external module "
f"{request.module_path}@{request.version}"
),
),
)

Then we can get all the metadata we need in a single go list invocation. That's great because Go tooling is very fast, whereas Pants has some overhead for running more Processes like setting up the sandbox. I'll try implementing this.

@stuhood
Copy link
Member

stuhood commented Oct 5, 2021

Target generation opens up a new possibility: dynamically inferring deps at target generation time, rather than dependency resolution time. Would it make sense to do that?

In general, I don't think so... Specs expansion is a really fundamental operation that would be good to keep fast. If we can defer things to when dependencies have actually been requested, that would be good I think.

On the other hand, it would probably be fine for the Go tooling to use a shared @rule to extract a shared metadata type containing all of the relevant info in the two codepaths. Effectively equivalent.

@Eric-Arellano
Copy link
Contributor Author

Eric-Arellano commented Oct 8, 2021

#13123 attempted this, but #13128 was a much better factoring. So, the answer is: no, it does not make sense to move to target generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Go Go backend-related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants