You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unit tests are currently sometimes ran in parallel and sometimes ran sequentially. This leads to a lot of tests running up front but still having a relatively long trail of tests which increases the amount of time needed to execute the unit tests. For example, here is CPU usage on my machine during the tests.
DONE 7180 tests, 6 skipped in 106.685s
There's an initial spike of CPU usage, but the second half of the test execution is much lower CPU execution as more tests are ran sequentially.
Motivation
This burns CI time (though not as much as the e2e tests), and slows down developers utilizing the make test functionality. As someone getting into to the codebase I find myself running make test frequently to ensure my changes aren't breaking other parts of the codebase.
I did a brief test using some ugly regex on my machine to get a ballpark number, and saw test runs drop to about a minute (test failures are due to my poor regexing and some tests not functioning in parallel).
Even if we get half the results, that's still saving ~25% of the execution time which seems like a reasonable tradeoff to add parallelism where possible.
Proposal
Where possible, we should be adding t.Parallel() to test functions and test runs. I think to make the work manageable this can be handled similar to #10592 with multiple PRs for smaller chunks to be updated.
Hi @NachoxMacho and @blakepettersson , I’d be interested in taking a first pass on this if nobody else is already working on it.
Given the failure rate from the broad regex-based experiment, I agree this seems best handled in small PRs rather than trying to parallelize everything at once.
My approach would be to start with one isolated subset of unit tests, review them for shared state or other parallel-safety concerns, add t.Parallel() only where isolation is clear, and then measure the impact before expanding further.
If that sounds reasonable, I can start with a small, low-risk batch first.
I think this is going to take multiple people and quite a few PRs in order to be done, so I don't think we need to worry too much about colliding on work.
Per the potential benefits, I do think spending time on parallelizing the non-trivial is where more of the benefit is going to be, and it's hard to get specific numbers as each run will be different. Even at an individual package level though, I think we will see more benefits. For example in just the applicationset controller test suite, adding parallelization reduce that unit test from a consistent 6-7 seconds to ~3 seconds.
Also from some brief analysis using vgt, I see numerous tails like this:
Where maybe a test or 2 is able to run in parallel but there is a long line of sequential tests unlike the middle of this where a whole suite of package tests can execute. This isn't the worst one I think small gains over the course of the execution would provide benefit.
Activity
test: add t.Parallel() to util jwt, crypto, and password tests (#27423)…
blakepettersson commentedon Apr 20, 2026
I did some initial testing and managed to only cut the total exec time down by ~8 seconds locally
I excluded ~2k tests which are not trivially parallelizable due to reasons. Perhaps the gains will be much larger if we could fix those ones as well
test: add t.Parallel() to util jwt, crypto, and password tests (argop…
test: add t.Parallel() to util jwt, crypto, and password tests (argop…
GuruduGanesh commentedon Apr 24, 2026
Hi @NachoxMacho and @blakepettersson , I’d be interested in taking a first pass on this if nobody else is already working on it.
Given the failure rate from the broad regex-based experiment, I agree this seems best handled in small PRs rather than trying to parallelize everything at once.
My approach would be to start with one isolated subset of unit tests, review them for shared state or other parallel-safety concerns, add
t.Parallel()only where isolation is clear, and then measure the impact before expanding further.If that sounds reasonable, I can start with a small, low-risk batch first.
test: add t.Parallel() to util jwt, crypto, and password tests (argop…
NachoxMacho commentedon Apr 29, 2026
I think this is going to take multiple people and quite a few PRs in order to be done, so I don't think we need to worry too much about colliding on work.
Per the potential benefits, I do think spending time on parallelizing the non-trivial is where more of the benefit is going to be, and it's hard to get specific numbers as each run will be different. Even at an individual package level though, I think we will see more benefits. For example in just the applicationset controller test suite, adding parallelization reduce that unit test from a consistent 6-7 seconds to ~3 seconds.
Also from some brief analysis using vgt, I see numerous tails like this:

Where maybe a test or 2 is able to run in parallel but there is a long line of sequential tests unlike the middle of this where a whole suite of package tests can execute. This isn't the worst one I think small gains over the course of the execution would provide benefit.
blakepettersson commentedon May 6, 2026
@NachoxMacho I did a bit more experimentation and I managed to cut the time down to ~80s. Great tip in regards to vgt!
blakepettersson commentedon May 7, 2026
Feel free to work on parallelizing the tests @NachoxMacho @GuruduGanesh
test: add t.Parallel() to util collections, io, rand, security tests (a…
test: add t.Parallel() to util collections, io, rand, security tests (a…
test: add t.Parallel() to util collections, io, rand, security tests (a…
test: add t.Parallel() to util collections, io, rand, security tests (#…
test: add t.Parallel() to util jwt, crypto, and password tests (argop…
test: Add t.Parallel() to util/app tests
test: Add t.Parallel() to util/app tests
test: Add t.Parallel() to util/app tests
test: Add t.Parallel() to util/ tests
test: Add t.Parallel() to util/ tests
test: Bulk-add t.Parallel() across util/ and fix global state races
test: Add t.Parallel() to unit tests across the codebase
test: Add t.Parallel() to unit tests across the codebase
test: add t.Parallel() to util collections, io, rand, security tests (a…
github-actions commentedon Aug 6, 2026
This issue has been marked as stale because it has had no activity for 90 days. Please comment if this is still relevant.