-
Notifications
You must be signed in to change notification settings - Fork 650
Add option to launch test with pprof profiling enabled #889
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an option to launch tests with pprof profiling enabled, enabling developers to trace slow tests.
- Introduces a global cpuprofile flag and integrates CPU profiling logic in runSingleConfigTest.
- Adds a new launch configuration template in VSCode to run tests with profiling enabled.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
internal/testrunner/compiler_runner.go | Adds cpuprofile flag and integrates pprof profiling within tests. |
.vscode/launch.template.json | Adds a launch configuration for running submodule tests with profiling. |
func (r *CompilerBaselineRunner) runSingleConfigTest(t *testing.T, testName string, test *compilerFileBasedTest, config *harnessutil.NamedTestConfiguration) { | ||
t.Parallel() | ||
defer testutil.RecoverAndFail(t, "Panic on compiling test "+test.filename) | ||
|
||
payload := makeUnitsFromTest(test.content, test.filename) | ||
compilerTest := newCompilerTest(t, testName, test.filename, &payload, config) | ||
|
||
if *cpuprofile != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using pprof.StartCPUProfile within a parallel test (set with t.Parallel()) may lead to concurrent invocations, which is not thread-safe as only one profile can run at a time. Consider restricting profiling to serial execution or adding synchronization to prevent overlapping profiling sessions.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably correct, but the expectation is you'll only invoke the test runner with profiling on for a single test, so.... 🤷
You actually don't need to do this manually;
|
Oh, excellent - I'll swap to a launch task for that, then. |
I imagine this is a useful launch task/flag for tracing slow tests - basically just pulled from the
go
docs.