Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
120597: kvcoord: use `sync.Map` for DistSender circuit breakers r=erikgrinaker a=erikgrinaker This has better concurrency properties, in that map scans don't have to hold long-lived locks. Such scans can otherwise cause high tail latency, since circuit breaker map lookups are on the RPC hot path. This adds about 20% overhead for circuit breaker construction, with 3 new allocations, but the request hot path overhead is negligible: ``` name old time/op new time/op delta DistSenderCircuitBreakersForReplica-24 2.69µs ± 1% 3.24µs ± 4% +20.06% (p=0.000 n=9+10) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=1-24 117ns ± 0% 120ns ± 1% +2.55% (p=0.000 n=7+9) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=16-24 193ns ±25% 181ns ±18% ~ (p=0.382 n=10+10) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=64-24 165ns ±25% 172ns ± 7% ~ (p=1.000 n=10+9) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=1024-24 142ns ±14% 169ns ±10% +18.82% (p=0.000 n=8+9) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=1-24 315ns ± 2% 326ns ± 2% +3.60% (p=0.000 n=10+10) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=16-24 795ns ± 6% 773ns ±11% ~ (p=0.780 n=9+10) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=64-24 853ns ± 4% 821ns ± 9% ~ (p=0.143 n=10+10) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=1024-24 898ns ± 5% 861ns ± 9% ~ (p=0.052 n=10+10) name old allocs/op new allocs/op delta DistSenderCircuitBreakersForReplica-24 13.0 ± 0% 16.0 ± 0% +23.08% (p=0.000 n=10+10) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=1-24 0.00 0.00 ~ (all equal) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=16-24 0.00 0.00 ~ (all equal) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=64-24 0.00 0.00 ~ (all equal) DistSenderCircuitBreakersTrack/cancel=false/alone=true/err=nil/conc=1024-24 0.00 0.00 ~ (all equal) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=1-24 2.00 ± 0% 2.00 ± 0% ~ (all equal) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=16-24 2.00 ± 0% 2.00 ± 0% ~ (all equal) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=64-24 2.00 ± 0% 2.00 ± 0% ~ (all equal) DistSenderCircuitBreakersTrack/cancel=true/alone=true/err=nil/conc=1024-24 2.00 ± 0% 2.00 ± 0% ~ (all equal) ``` Touches cockroachdb#119919. Epic: none Release note: None Co-authored-by: Erik Grinaker <[email protected]>
- Loading branch information