🐛 fix: eliminate data races in parallel router benchmarks#4044
🐛 fix: eliminate data races in parallel router benchmarks#4044gaby merged 3 commits intoadd-parallel-benchmarks-to-test-filesfrom
Conversation
Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## add-parallel-benchmarks-to-test-files #4044 +/- ##
=========================================================================
- Coverage 91.19% 91.15% -0.04%
=========================================================================
Files 119 119
Lines 11117 11117
=========================================================================
- Hits 10138 10134 -4
- Misses 621 625 +4
Partials 358 358
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9be4804
into
add-parallel-benchmarks-to-test-files
There was a problem hiding this comment.
Pull request overview
This PR refactors several parallel router benchmarks to eliminate data races and make the results deterministic under -race, while preserving correctness checks via single-threaded verification passes.
Changes:
Benchmark_App_RebuildTree_Parallelnow creates a worker-localAppand route set in each goroutine instead of mutating shared state (routesRefreshed) across goroutines.Benchmark_App_MethodNotAllowed_ParallelandBenchmark_Route_Match_Parallelnow use worker-local state inRunParallel, with correctness verified afterward on a fresh context/params in a single goroutine.Benchmark_Router_GitHub_API_Parallelnow uses per-workerRequestCtxand eliminates sharedmatch/errvariables, with per-route correctness verified serially after each parallel run.
Description
Parallel benchmarks in
router_test.goshared mutable state across goroutines, causing data races under-raceand non-deterministic test failures. TheBenchmark_App_MethodNotAllowed_Parallelbenchmark failed CI with race conditions on response headers.Changes introduced
Fixed data races in four parallel benchmarks:
Benchmark_App_RebuildTree_Parallel- Each worker now creates its ownAppinstance instead of mutating sharedapp.routesRefreshedBenchmark_App_MethodNotAllowed_Parallel- Worker-localRequestCtxper goroutine with post-benchmark verificationBenchmark_Router_GitHub_API_Parallel- Eliminated sharedmatch/errvariables; worker-local contextsBenchmark_Route_Match_Parallel- Worker-localparamsarrays with separate verificationPattern applied:
-racedetector; no performance regressionType of change
Checklist
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.