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: support the go test profiling options #17836

Merged
merged 10 commits into from Dec 18, 2022

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Dec 17, 2022

Support the go test profiling options which take various profiles of a test run (e.g., CPU, memory, etc.). The profiles are output via the extra_output field on TestResult. Also includes the ability to export the compiled test binary (which is needed for analysis of some of the profiles).

Closes #16610.

@tdyas tdyas added backend: Go Go backend-related issues category:new feature labels Dec 17, 2022
@@ -540,6 +593,11 @@ async def run_go_tests(
pkg_target_address=field_set.address,
)

output_files = [x for x in output_files if x != "cover.out"]
if output_files:
# TODO: What is the best way to arrange for these files to be output?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjyw / @Eric-Arellano: The remaining question in this PR is how exactly should ancillary profile files be written to disk?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(given that the rule returns TestResult). The extra_output attribute does not appear to be used at all to write output out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm looks like it is written out

workspace.write_digest(
result.extra_output.digest,
path_prefix=str(distdir.relpath / "test" / result.path_safe_description),
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest commit just has the profiles be extra output from the test run.

@tdyas tdyas changed the title [WIP] go: support the go test profiling options go: support the go test profiling options Dec 17, 2022
@tdyas tdyas marked this pull request as ready for review December 17, 2022 22:49
Copy link
Sponsor Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice when the standard test runner handles profiling rather than a mishmash of external tools!

@tdyas tdyas merged commit 18618c1 into pantsbuild:main Dec 18, 2022
@tdyas tdyas deleted the golang_test_capture_profiling branch December 18, 2022 10:48
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 category:new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go: support capturing test profile outputs
2 participants