Skip to content

profiler: stop using runProfile in tests #3590

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

nsrip-dd
Copy link
Contributor

@nsrip-dd nsrip-dd commented Jun 3, 2025

In general, we should prefer testing the profiler with as close to the API
customers will use as possible. For one, it gives us more confidence that
customers will get the data they expect. Also, it's been a pain to work on the
profiler when internals-only changes break tests that happen to depend on the
internals of the profiler, such as TestRunProfile. This change starts getting
rid of uses of runProfile in particular.

This change gets rid of the CPU and goroutine sub-tests in TestRunProfile since
they really don't assert anything meaningful (other tests already check that
those profiles are present, and mocking their contents doesn't tell us
anything on top of that). For the goroutine wait profile sub-tests, we can at
least remove the dependency on run profile. This change moves those sub-tests
to their own test functions, TestGoroutineWait and TestGoroutinesWaitLimit. For
TestGoroutineWait, we are basically testing converting a debug goroutine
profile to a pprof, so the tests opts to use goroutineDebug2ToPprof directly
rather than hook into the profiler. For TestGoroutinesWaitLimit, we use
startTestProfiler, which is more end-to-end, and make assertions about the
profiles we would upload and the logs we would emit instead of hooking in to
the profiler.

TODO - tackle the "delta" test. We already test the delta implementation pretty
extensively, but it might be good to have some kind of more "end-to-end" test
for that. If we can remove the bits where we hook into the profiler there, I
think we can get rid of the testHooks stuff.

In general, we should prefer testing the profiler with as close to the
API customers will use as possible. For one, it gives us more confidence
that customers will get the data they expect. Also, it's been a pain to
work on the profiler when internals-only changes break tests that happen
to depend on the internals of the profiler, such as TestRunProfile. This
change starts getting rid of uses of runProfile in particular.

This change gets rid of the CPU and goroutine sub-tests in
TestRunProfile since they really don't assert anything meaningful (other
tests already check that those profiles are _present_, and mocking their
contents doesn't tell us anything on top of that). For the goroutine
wait profile sub-tests, we can at least remove the dependency on run
profile. This change moves those sub-tests to their own test functions,
TestGoroutineWait and TestGoroutinesWaitLimit. For TestGoroutineWait, we
are basically testing converting a debug goroutine profile to a pprof,
so the tests opts to use goroutineDebug2ToPprof directly rather than
hook into the profiler. For TestGoroutinesWaitLimit, we use
startTestProfiler, which is more end-to-end, and make assertions about
the profiles we would upload and the logs we would emit instead of
hooking in to the profiler.
@pr-commenter
Copy link

pr-commenter bot commented Jun 3, 2025

Benchmarks

Benchmark execution time: 2025-06-03 19:03:28

Comparing candidate commit 93dc756 in PR branch push-vvpltltrvozv with baseline commit 3f3373d in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 21 metrics, 0 unstable metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant