diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.BridgeBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.BridgeBenchmark-report-github.md index 8c891417d2c..9019c3d150f 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.BridgeBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.BridgeBenchmark-report-github.md @@ -1,15 +1,15 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | -|----------------------- |----------:|---------:|---------:|------:|--------:|-------:|----------:|------------:| -| NoOpAsync | 67.10 ns | 4.915 ns | 6.890 ns | 1.00 | 0.00 | 0.0120 | 304 B | 1.00 | -| NullResiliencePipeline | 363.47 ns | 3.895 ns | 5.830 ns | 5.45 | 0.56 | 0.0148 | 376 B | 1.24 | +| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|----------------------- |----------:|---------:|----------:|------:|--------:|-------:|----------:|------------:| +| NoOpAsync | 84.05 ns | 4.660 ns | 6.830 ns | 1.01 | 0.11 | 0.0242 | 304 B | 1.00 | +| NullResiliencePipeline | 241.69 ns | 8.178 ns | 12.240 ns | 2.89 | 0.27 | 0.0296 | 376 B | 1.24 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerBenchmark-report-github.md index 017a9867fee..6fef2bcba85 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerBenchmark-report-github.md @@ -1,9 +1,9 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 @@ -11,5 +11,5 @@ LaunchCount=2 WarmupCount=10 ``` | Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | |------------------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| -| ExecuteCircuitBreaker_V7 | 228.6 ns | 2.19 ns | 3.21 ns | 1.00 | 0.00 | 0.0200 | 504 B | 1.00 | -| ExecuteCircuitBreaker_V8 | 411.8 ns | 0.41 ns | 0.60 ns | 1.80 | 0.03 | - | - | 0.00 | +| ExecuteCircuitBreaker_V7 | 207.1 ns | 3.68 ns | 5.50 ns | 1.00 | 0.04 | 0.0370 | 464 B | 1.00 | +| ExecuteCircuitBreaker_V8 | 335.3 ns | 6.30 ns | 9.43 ns | 1.62 | 0.06 | - | - | 0.00 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerOpenedBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerOpenedBenchmark-report-github.md index 71693caa38b..246766f6d30 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerOpenedBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CircuitBreakerOpenedBenchmark-report-github.md @@ -1,16 +1,16 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | -|-------------------------- |------------:|---------:|---------:|------:|--------:|-------:|----------:|------------:| -| ExecuteAsync_Exception_V7 | 23,229.9 ns | 26.25 ns | 39.29 ns | 36.23 | 0.20 | 0.0916 | 2504 B | 13.04 | -| ExecuteAsync_Exception_V8 | 15,832.2 ns | 29.74 ns | 43.59 ns | 24.69 | 0.16 | 0.0610 | 1816 B | 9.46 | -| ExecuteAsync_Outcome_V8 | 641.2 ns | 2.07 ns | 2.97 ns | 1.00 | 0.00 | 0.0076 | 192 B | 1.00 | +| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|-------------------------- |------------:|----------:|----------:|------:|--------:|-------:|----------:|------------:| +| ExecuteAsync_Exception_V7 | 14,295.0 ns | 418.44 ns | 600.11 ns | 27.37 | 1.33 | 0.1526 | 2056 B | 10.28 | +| ExecuteAsync_Exception_V8 | 9,178.8 ns | 114.83 ns | 171.88 ns | 17.57 | 0.55 | 0.0916 | 1312 B | 6.56 | +| ExecuteAsync_Outcome_V8 | 522.6 ns | 9.15 ns | 13.70 ns | 1.00 | 0.04 | 0.0153 | 200 B | 1.00 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CompositeComponentBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CompositeComponentBenchmark-report-github.md index 13fda9f5cbc..235297dd8a0 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CompositeComponentBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CompositeComponentBenchmark-report-github.md @@ -1,9 +1,9 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 @@ -11,4 +11,4 @@ LaunchCount=2 WarmupCount=10 ``` | Method | Mean | Error | StdDev | Allocated | |------------------------------- |---------:|---------:|---------:|----------:| -| CompositeComponent_ExecuteCore | 37.44 ns | 1.419 ns | 1.990 ns | - | +| CompositeComponent_ExecuteCore | 40.70 ns | 0.574 ns | 0.823 ns | - | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CreationBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CreationBenchmark-report-github.md index 23b7cb5d98c..e928f0c6174 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CreationBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.CreationBenchmark-report-github.md @@ -1,15 +1,15 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Median | Gen0 | Allocated | -|------------ |------------:|----------:|----------:|------------:|-------:|----------:| -| Fallback_V7 | 78.52 ns | 3.274 ns | 4.901 ns | 76.04 ns | 0.0191 | 480 B | -| Fallback_V8 | 2,832.14 ns | 11.383 ns | 17.037 ns | 2,832.55 ns | 0.2251 | 5704 B | +| Method | Mean | Error | StdDev | Gen0 | Allocated | +|------------ |------------:|----------:|----------:|-------:|----------:| +| Fallback_V7 | 63.30 ns | 1.058 ns | 1.583 ns | 0.0305 | 384 B | +| Fallback_V8 | 2,689.59 ns | 34.384 ns | 50.400 ns | 0.4082 | 5136 B | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.DelegatingComponentBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.DelegatingComponentBenchmark-report-github.md index 3c19d8edb26..8666296ea08 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.DelegatingComponentBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.DelegatingComponentBenchmark-report-github.md @@ -1,9 +1,9 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 @@ -11,5 +11,5 @@ LaunchCount=2 WarmupCount=10 ``` | Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | |------------------------------------ |---------:|---------:|---------:|------:|--------:|-------:|----------:|------------:| -| DelegatingComponent_ExecuteCore_Jit | 23.53 ns | 0.026 ns | 0.037 ns | 1.00 | 0.00 | - | - | NA | -| DelegatingComponent_ExecuteCore_Aot | 33.34 ns | 0.837 ns | 1.228 ns | 1.42 | 0.05 | 0.0010 | 24 B | NA | +| DelegatingComponent_ExecuteCore_Jit | 29.17 ns | 0.613 ns | 0.899 ns | 1.00 | 0.04 | - | - | NA | +| DelegatingComponent_ExecuteCore_Aot | 43.48 ns | 0.584 ns | 0.873 ns | 1.49 | 0.05 | 0.0019 | 24 B | NA | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.GenericOverheadBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.GenericOverheadBenchmark-report-github.md index 2c35666684c..f8c88a3cd86 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.GenericOverheadBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.GenericOverheadBenchmark-report-github.md @@ -1,15 +1,15 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Allocated | Alloc Ratio | -|------------------------ |---------:|---------:|---------:|---------:|------:|--------:|----------:|------------:| -| ExecuteAsync_Generic | 11.58 ns | 0.220 ns | 0.323 ns | 11.75 ns | 1.00 | 0.00 | - | NA | -| ExecuteAsync_NonGeneric | 19.25 ns | 0.026 ns | 0.038 ns | 19.25 ns | 1.66 | 0.05 | - | NA | +| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | +|------------------------ |---------:|---------:|---------:|------:|--------:|----------:|------------:| +| ExecuteAsync_Generic | 14.67 ns | 0.266 ns | 0.390 ns | 1.00 | 0.04 | - | NA | +| ExecuteAsync_NonGeneric | 24.89 ns | 0.581 ns | 0.870 ns | 1.70 | 0.07 | - | NA | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.HedgingBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.HedgingBenchmark-report-github.md index 4f64e3eb9fa..264b1e72584 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.HedgingBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.HedgingBenchmark-report-github.md @@ -1,17 +1,17 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | -|---------------------------- |----------:|----------:|----------:|------:|--------:|-------:|----------:|------------:| -| Hedging_Primary | 1.139 μs | 0.0058 μs | 0.0087 μs | 1.00 | 0.00 | - | 40 B | 1.00 | -| Hedging_Secondary | 1.789 μs | 0.0262 μs | 0.0393 μs | 1.57 | 0.04 | 0.0095 | 280 B | 7.00 | -| Hedging_Primary_AsyncWork | 6.274 μs | 0.4927 μs | 0.7374 μs | 5.51 | 0.65 | 0.0916 | 2325 B | 58.12 | -| Hedging_Secondary_AsyncWork | 12.488 μs | 0.7955 μs | 1.1907 μs | 10.97 | 1.07 | 0.0916 | 2606 B | 65.15 | +| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|---------------------------- |-----------:|----------:|----------:|------:|--------:|-------:|----------:|------------:| +| Hedging_Primary | 684.6 ns | 25.04 ns | 36.71 ns | 1.00 | 0.07 | - | - | NA | +| Hedging_Secondary | 1,192.5 ns | 24.41 ns | 34.21 ns | 1.75 | 0.10 | 0.0191 | 240 B | NA | +| Hedging_Primary_AsyncWork | 5,504.3 ns | 313.47 ns | 449.58 ns | 8.06 | 0.77 | 0.1831 | 2338 B | NA | +| Hedging_Secondary_AsyncWork | 6,123.1 ns | 98.34 ns | 144.15 ns | 8.97 | 0.50 | 0.2060 | 2577 B | NA | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.MultipleStrategiesBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.MultipleStrategiesBenchmark-report-github.md index 84b3204a633..9fd03303b05 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.MultipleStrategiesBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.MultipleStrategiesBenchmark-report-github.md @@ -1,18 +1,18 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | -|----------------------------------------------- |---------:|----------:|----------:|------:|--------:|-------:|----------:|------------:| -| ExecuteStrategyPipeline_Generic_V7 | 2.626 μs | 0.4061 μs | 0.5824 μs | 1.00 | 0.00 | 0.1106 | 2824 B | 1.00 | -| ExecuteStrategyPipeline_Generic_V8 | 1.853 μs | 0.0380 μs | 0.0556 μs | 0.74 | 0.18 | - | 40 B | 0.01 | -| ExecuteStrategyPipeline_GenericTelemetry_V8 | 2.647 μs | 0.0401 μs | 0.0600 μs | 1.06 | 0.22 | - | 40 B | 0.01 | -| ExecuteStrategyPipeline_NonGeneric_V8 | 2.059 μs | 0.0292 μs | 0.0418 μs | 0.82 | 0.18 | - | 40 B | 0.01 | -| ExecuteStrategyPipeline_NonGenericTelemetry_V8 | 2.934 μs | 0.0150 μs | 0.0220 μs | 1.17 | 0.26 | - | 40 B | 0.01 | +| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|----------------------------------------------- |---------:|----------:|----------:|---------:|------:|--------:|-------:|----------:|------------:| +| ExecuteStrategyPipeline_Generic_V7 | 1.180 μs | 0.0082 μs | 0.0122 μs | 1.179 μs | 1.00 | 0.01 | 0.2174 | 2744 B | 1.00 | +| ExecuteStrategyPipeline_Generic_V8 | 1.082 μs | 0.0128 μs | 0.0180 μs | 1.078 μs | 0.92 | 0.02 | 0.0019 | 40 B | 0.01 | +| ExecuteStrategyPipeline_GenericTelemetry_V8 | 1.566 μs | 0.0178 μs | 0.0255 μs | 1.552 μs | 1.33 | 0.03 | 0.0019 | 40 B | 0.01 | +| ExecuteStrategyPipeline_NonGeneric_V8 | 1.150 μs | 0.0052 μs | 0.0075 μs | 1.148 μs | 0.97 | 0.01 | 0.0019 | 40 B | 0.01 | +| ExecuteStrategyPipeline_NonGenericTelemetry_V8 | 1.672 μs | 0.0075 μs | 0.0110 μs | 1.672 μs | 1.42 | 0.02 | 0.0019 | 40 B | 0.01 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PipelineBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PipelineBenchmark-report-github.md index d1b180a16fc..e1206f86536 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PipelineBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PipelineBenchmark-report-github.md @@ -1,24 +1,24 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Components | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio | -|------------------- |----------- |------------:|---------:|----------:|------:|-------:|----------:|------------:| -| **ExecutePipeline_V7** | **1** | **90.13 ns** | **0.834 ns** | **1.249 ns** | **1.00** | **0.0120** | **304 B** | **1.00** | -| ExecutePipeline_V8 | 1 | 73.47 ns | 0.254 ns | 0.373 ns | 0.82 | - | - | 0.00 | -| | | | | | | | | | -| **ExecutePipeline_V7** | **2** | **233.68 ns** | **1.506 ns** | **2.208 ns** | **1.00** | **0.0219** | **552 B** | **1.00** | -| ExecutePipeline_V8 | 2 | 114.89 ns | 0.212 ns | 0.291 ns | 0.49 | - | - | 0.00 | -| | | | | | | | | | -| **ExecutePipeline_V7** | **5** | **778.86 ns** | **4.387 ns** | **6.566 ns** | **1.00** | **0.0515** | **1296 B** | **1.00** | -| ExecutePipeline_V8 | 5 | 374.64 ns | 0.452 ns | 0.619 ns | 0.48 | - | - | 0.00 | -| | | | | | | | | | -| **ExecutePipeline_V7** | **10** | **1,706.53 ns** | **8.257 ns** | **12.359 ns** | **1.00** | **0.0992** | **2536 B** | **1.00** | -| ExecutePipeline_V8 | 10 | 775.52 ns | 3.341 ns | 4.792 ns | 0.45 | - | - | 0.00 | +| Method | Components | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|------------------- |----------- |----------:|---------:|----------:|------:|--------:|-------:|----------:|------------:| +| **ExecutePipeline_V7** | **1** | **69.79 ns** | **0.588 ns** | **0.880 ns** | **1.00** | **0.02** | **0.0242** | **304 B** | **1.00** | +| ExecutePipeline_V8 | 1 | 69.75 ns | 0.290 ns | 0.406 ns | 1.00 | 0.01 | - | - | 0.00 | +| | | | | | | | | | | +| **ExecutePipeline_V7** | **2** | **151.17 ns** | **1.092 ns** | **1.566 ns** | **1.00** | **0.01** | **0.0439** | **552 B** | **1.00** | +| ExecutePipeline_V8 | 2 | 99.85 ns | 0.617 ns | 0.884 ns | 0.66 | 0.01 | - | - | 0.00 | +| | | | | | | | | | | +| **ExecutePipeline_V7** | **5** | **409.27 ns** | **3.791 ns** | **5.314 ns** | **1.00** | **0.02** | **0.1030** | **1296 B** | **1.00** | +| ExecutePipeline_V8 | 5 | 208.08 ns | 0.874 ns | 1.280 ns | 0.51 | 0.01 | - | - | 0.00 | +| | | | | | | | | | | +| **ExecutePipeline_V7** | **10** | **822.12 ns** | **6.901 ns** | **10.115 ns** | **1.00** | **0.02** | **0.2012** | **2536 B** | **1.00** | +| ExecutePipeline_V8 | 10 | 399.00 ns | 1.668 ns | 2.393 ns | 0.49 | 0.01 | - | - | 0.00 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PredicateBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PredicateBenchmark-report-github.md index 319f8e5b387..ed910b82186 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PredicateBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.PredicateBenchmark-report-github.md @@ -1,15 +1,15 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | -|--------------------------- |----------:|----------:|----------:|------:|--------:|----------:|------------:| -| Predicate_SwitchExpression | 9.628 ns | 0.0755 ns | 0.1082 ns | 1.00 | 0.00 | - | NA | -| Predicate_PredicateBuilder | 27.885 ns | 0.1972 ns | 0.2890 ns | 2.90 | 0.04 | - | NA | +| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Allocated | Alloc Ratio | +|--------------------------- |---------:|---------:|---------:|---------:|------:|--------:|----------:|------------:| +| Predicate_SwitchExpression | 11.82 ns | 0.234 ns | 0.343 ns | 12.08 ns | 1.00 | 0.04 | - | NA | +| Predicate_PredicateBuilder | 21.52 ns | 0.077 ns | 0.108 ns | 21.51 ns | 1.82 | 0.05 | - | NA | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RateLimiterBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RateLimiterBenchmark-report-github.md index af02211026d..04c0bcb6355 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RateLimiterBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RateLimiterBenchmark-report-github.md @@ -1,15 +1,15 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | -|---------------------- |---------:|--------:|--------:|---------:|------:|--------:|-------:|----------:|------------:| -| ExecuteRateLimiter_V7 | 227.1 ns | 3.06 ns | 4.39 ns | 227.1 ns | 1.00 | 0.00 | 0.0148 | 376 B | 1.00 | -| ExecuteRateLimiter_V8 | 215.0 ns | 1.17 ns | 1.72 ns | 214.2 ns | 0.95 | 0.02 | 0.0014 | 40 B | 0.11 | +| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio | +|---------------------- |---------:|--------:|--------:|------:|-------:|----------:|------------:| +| ExecuteRateLimiter_V7 | 178.3 ns | 0.79 ns | 1.16 ns | 1.00 | 0.0298 | 376 B | 1.00 | +| ExecuteRateLimiter_V8 | 188.2 ns | 0.89 ns | 1.34 ns | 1.06 | 0.0031 | 40 B | 0.11 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineBenchmark-report-github.md index e69c4546bc0..f71578b970b 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineBenchmark-report-github.md @@ -1,20 +1,20 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | -|----------------------------------------------- |----------:|---------:|---------:|------:|--------:|----------:|------------:| -| ExecuteOutcomeAsync | 44.54 ns | 0.395 ns | 0.579 ns | 1.00 | 0.00 | - | NA | -| ExecuteAsync_ResilienceContextAndState | 130.02 ns | 0.845 ns | 1.212 ns | 2.92 | 0.04 | - | NA | -| ExecuteAsync_CancellationToken | 149.78 ns | 1.103 ns | 1.617 ns | 3.36 | 0.05 | - | NA | -| ExecuteAsync_GenericStrategy_CancellationToken | 146.42 ns | 0.077 ns | 0.115 ns | 3.29 | 0.04 | - | NA | -| Execute_ResilienceContextAndState | 45.44 ns | 0.524 ns | 0.768 ns | 1.02 | 0.03 | - | NA | -| Execute_CancellationToken | 69.38 ns | 1.320 ns | 1.894 ns | 1.56 | 0.05 | - | NA | -| Execute_GenericStrategy_CancellationToken | 67.92 ns | 0.542 ns | 0.760 ns | 1.53 | 0.02 | - | NA | +| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | +|----------------------------------------------- |---------:|---------:|---------:|------:|--------:|----------:|------------:| +| ExecuteOutcomeAsync | 45.69 ns | 0.443 ns | 0.635 ns | 1.00 | 0.02 | - | NA | +| ExecuteAsync_ResilienceContextAndState | 80.17 ns | 0.672 ns | 1.006 ns | 1.76 | 0.03 | - | NA | +| ExecuteAsync_CancellationToken | 84.26 ns | 0.285 ns | 0.381 ns | 1.84 | 0.03 | - | NA | +| ExecuteAsync_GenericStrategy_CancellationToken | 87.55 ns | 3.675 ns | 5.030 ns | 1.92 | 0.11 | - | NA | +| Execute_ResilienceContextAndState | 59.59 ns | 0.610 ns | 0.894 ns | 1.30 | 0.03 | - | NA | +| Execute_CancellationToken | 66.67 ns | 0.542 ns | 0.794 ns | 1.46 | 0.03 | - | NA | +| Execute_GenericStrategy_CancellationToken | 67.05 ns | 0.632 ns | 0.906 ns | 1.47 | 0.03 | - | NA | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineProviderBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineProviderBenchmark-report-github.md index 575c74c33cf..0c46d21cc1a 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineProviderBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.ResiliencePipelineProviderBenchmark-report-github.md @@ -1,9 +1,9 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 @@ -11,5 +11,5 @@ LaunchCount=2 WarmupCount=10 ``` | Method | Mean | Error | StdDev | Allocated | |----------------------- |---------:|---------:|---------:|----------:| -| GetPipeline_Ok | 13.53 ns | 0.128 ns | 0.183 ns | - | -| GetPipeline_Generic_Ok | 39.91 ns | 0.499 ns | 0.731 ns | - | +| GetPipeline_Ok | 11.51 ns | 0.046 ns | 0.068 ns | - | +| GetPipeline_Generic_Ok | 43.64 ns | 0.146 ns | 0.214 ns | - | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RetryBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RetryBenchmark-report-github.md index 101da313f78..0722a1a8566 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RetryBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.RetryBenchmark-report-github.md @@ -1,9 +1,9 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 @@ -11,5 +11,5 @@ LaunchCount=2 WarmupCount=10 ``` | Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | |---------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| -| ExecuteRetry_V7 | 207.9 ns | 4.04 ns | 6.05 ns | 1.00 | 0.00 | 0.0219 | 552 B | 1.00 | -| ExecuteRetry_V8 | 255.9 ns | 2.53 ns | 3.79 ns | 1.23 | 0.04 | - | - | 0.00 | +| ExecuteRetry_V7 | 125.4 ns | 0.84 ns | 1.20 ns | 1.00 | 0.01 | 0.0408 | 512 B | 1.00 | +| ExecuteRetry_V8 | 179.7 ns | 0.61 ns | 0.87 ns | 1.43 | 0.02 | - | - | 0.00 | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TelemetryBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TelemetryBenchmark-report-github.md index 23ed2afcb21..85274a206b3 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TelemetryBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TelemetryBenchmark-report-github.md @@ -1,17 +1,17 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Telemetry | Enrichment | Mean | Error | StdDev | Median | Allocated | -|-------- |---------- |----------- |----------:|---------:|----------:|----------:|----------:| -| **Execute** | **False** | **False** | **70.29 ns** | **1.936 ns** | **2.651 ns** | **69.94 ns** | **-** | -| **Execute** | **False** | **True** | **70.77 ns** | **0.214 ns** | **0.300 ns** | **70.68 ns** | **-** | -| **Execute** | **True** | **False** | **675.67 ns** | **3.703 ns** | **5.542 ns** | **675.58 ns** | **-** | -| **Execute** | **True** | **True** | **883.36 ns** | **8.840 ns** | **12.957 ns** | **872.21 ns** | **-** | +| Method | Telemetry | Enrichment | Mean | Error | StdDev | Allocated | +|-------- |---------- |----------- |----------:|---------:|---------:|----------:| +| **Execute** | **False** | **False** | **60.58 ns** | **0.178 ns** | **0.256 ns** | **-** | +| **Execute** | **False** | **True** | **62.53 ns** | **1.442 ns** | **2.159 ns** | **-** | +| **Execute** | **True** | **False** | **443.92 ns** | **1.736 ns** | **2.434 ns** | **-** | +| **Execute** | **True** | **True** | **612.90 ns** | **2.974 ns** | **4.359 ns** | **-** | diff --git a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TimeoutBenchmark-report-github.md b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TimeoutBenchmark-report-github.md index b8debed9465..0f07f118245 100644 --- a/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TimeoutBenchmark-report-github.md +++ b/bench/BenchmarkDotNet.Artifacts/results/Polly.Core.Benchmarks.TimeoutBenchmark-report-github.md @@ -1,15 +1,15 @@ ``` -BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3) (Hyper-V) -Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores -.NET SDK 8.0.100 - [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI +BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3) +12th Gen Intel Core i7-1280P, 1 CPU, 20 logical and 14 physical cores +.NET SDK 9.0.101 + [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2 Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=2 WarmupCount=10 ``` -| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio | -|------------------ |---------:|--------:|--------:|------:|-------:|----------:|------------:| -| ExecuteTimeout_V7 | 316.3 ns | 2.54 ns | 3.80 ns | 1.00 | 0.0286 | 728 B | 1.00 | -| ExecuteTimeout_V8 | 277.5 ns | 0.26 ns | 0.38 ns | 0.88 | - | - | 0.00 | +| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|------------------ |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| +| ExecuteTimeout_V7 | 259.3 ns | 4.25 ns | 6.24 ns | 1.00 | 0.03 | 0.0577 | 728 B | 1.00 | +| ExecuteTimeout_V8 | 241.1 ns | 1.48 ns | 2.17 ns | 0.93 | 0.02 | - | - | 0.00 | diff --git a/src/Polly.Core/Utils/ValidationHelper.cs b/src/Polly.Core/Utils/ValidationHelper.cs index 97b05873e00..bfcca231ce9 100644 --- a/src/Polly.Core/Utils/ValidationHelper.cs +++ b/src/Polly.Core/Utils/ValidationHelper.cs @@ -7,6 +7,9 @@ namespace Polly.Utils; [ExcludeFromCodeCoverage] internal static class ValidationHelper { + // Workaround for https://github.com/dotnet/runtime/issues/110917 + private static readonly object ValidatorLock = new(); + public static string[]? GetMemberName(this ValidationContext? validationContext) => #pragma warning disable S1168 // Empty arrays and collections should be returned instead of null validationContext?.MemberName is { } memberName @@ -26,9 +29,15 @@ public static void ValidateObject(ResilienceValidationContext context) { Guard.NotNull(context); + bool valid; var errors = new List(); - if (!Validator.TryValidateObject(context.Instance, new ValidationContext(context.Instance), errors, true)) + lock (ValidatorLock) + { + valid = Validator.TryValidateObject(context.Instance, new(context.Instance), errors, true); + } + + if (!valid) { var stringBuilder = new StringBuilder(context.PrimaryMessage); stringBuilder.AppendLine(); diff --git a/test/Polly.Core.Tests/Utils/ValidationHelperTests.cs b/test/Polly.Core.Tests/Utils/ValidationHelperTests.cs index 5228289db98..57036d539ea 100644 --- a/test/Polly.Core.Tests/Utils/ValidationHelperTests.cs +++ b/test/Polly.Core.Tests/Utils/ValidationHelperTests.cs @@ -31,4 +31,45 @@ public void GetDisplayName_Ok() context = new ValidationContext(new object()) { DisplayName = "X" }; context.GetDisplayName().Should().Be("X"); } + + /// + /// Test for validator concurrency issue. + /// + [Fact] + public void ValidateObject_SynchronizesValidation() + { + var detector = new ConcurrencyDetector(); + Parallel.For(0, 2, _ => ValidationHelper.ValidateObject(new(new TestOptions(detector), string.Empty))); + + detector.InvokedConcurrently.Should().BeFalse(); + } + + private sealed class TestOptions(ConcurrencyDetector detector) : IValidatableObject + { + public IEnumerable Validate(ValidationContext validationContext) + { + detector.Execute(); + yield break; + } + } + + private sealed class ConcurrencyDetector + { + private readonly object _sync = new(); + + public bool InvokedConcurrently { get; private set; } + + public void Execute() + { + if (Monitor.TryEnter(_sync)) + { + Thread.Sleep(1); + Monitor.Exit(_sync); + } + else + { + InvokedConcurrently = true; + } + } + } }