Skip to main content

Benchmarks

Kevlar vs Polly v8 across every strategy, measured with BenchmarkDotNet on GitHub Actions and republished automatically by the benchmarks workflow.

Last updated 2026-11-10 05:44 UTC (commit 306a424).

note

Microbenchmarks on shared CI runners are noisy. The vs Polly column is the median ratio over the most recent runs (up to 10); anything within ±20% is reported as on par. Absolute times move with runner hardware — the ratios are the signal.

Pipeline overhead floor​

What an empty pipeline costs per execution — the fixed tax every strategy builds on.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Empty pipeline — async18.5 ns41.3 ns0 B0 B3.4× faster
Empty pipeline — reference-state baseline14.6 ns—0 B——
Empty pipeline — caller-seeded context65.5 ns—0 B——
EmptyOutcomeState10.0 ns—0 B——
EmptyTaskOutcomeState12.5 ns—0 B——
Empty pipeline — zero-closure state overload26.2 ns41.5 ns0 B0 B3.5× faster
Empty pipeline — sync9.6 ns29.8 ns0 B0 B3.4× faster
NestedEmptyAsync101 ns—0 B——
NestedEmptySync101 ns—0 B——
NestedWithPropertiesAsync149 ns—0 B——
NestedWithPropertiesSync155 ns—0 B——

Retry​

Happy path (judge overhead only) and a recovery path where every call fails twice before succeeding, with backoff disabled so only strategy machinery is measured.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Retry(3) — success on first attempt138 ns238 ns0 B24 B2.0× faster
Retry(3) — two failures then success4.35 μs4.60 μs192 B328 Bon par

Timeout​

The timeout never fires; this is the cost of arming and disarming the cancellation plumbing on every call.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Timeout(10 s) — completes instantly174 ns187 ns0 B0 B1.2× faster
SynchronousGenerator_HappyPath216 ns—0 B——
AsynchronousGenerator_HappyPath1.63 μs—559 B——
AsyncHookConfigured_HappyPath211 ns—0 B——

Circuit breaker​

Ratio/sampling bookkeeping while closed, and the fast-fail rejection cost while manually isolated — caught as a thrown exception, and read from the no-throw ExecuteOutcomeAsync API.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Isolated circuit — fast-fail rejection thrown5.51 μs5.71 μs1.3 KB1.3 KBon par
Isolated circuit — fast-fail rejection via ExecuteOutcomeAsync110 ns182 ns144 B200 B1.7× faster
Ratio breaker, closed — success178 ns243 ns0 B24 B1.5× faster
DynamicDurationConfigured233 ns—0 B——
AsyncCallbackConfigured208 ns—0 B——
SlowCallDetectionConfigured289 ns—0 B——

Circuit breaker under contention​

Eight workers share one open circuit, so every call is a fast-fail rejection observed as an outcome; this is the per-call cost during an outage.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Open circuit — 8 workers rejected63.5 ns199 ns144 B200 B3.1× faster

Fallback​

Pass-through when the execution succeeds, and substitution when it throws.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
NoNotification2.50 μs—200 B——
CompletedAsyncNotification2.48 μs—200 B——
YieldingAsyncNotification6.52 μs—807 B——
Fallback — not triggered134 ns122 ns0 B0 Bon par
SynchronousDelegate_Triggered2.42 μs—200 B——
Fallback — triggered by exception2.56 μs2.56 μs200 B256 Bon par
EmptyVoid44.3 ns—0 B——
VoidPassThrough174 ns—0 B——

Rate limit​

Uncontended token-bucket permit acquisition — every call is admitted — and the rejection cost once the budget is exhausted, thrown vs ExecuteOutcomeAsync.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Budget exhausted — rejection thrown5.60 μs69.61 μs1.3 KB41.4 KB12× faster
Budget exhausted — rejection via ExecuteOutcomeAsync150 ns46.04 μs136 B35.5 KB291× faster
Token bucket — uncontended acquire152 ns129 ns0 B0 Bon par
WithHooks_Uncontended155 ns—0 B——
FrameworkAdapter_Uncontended147 ns—0 B——
PartitionedFrameworkAdapter_Uncontended178 ns—32 B——

Concurrency limit​

A single caller against a large permit count; acquire/release cost with no queueing. The rejection rows hold the only permit and compare thrown vs ExecuteOutcomeAsync.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Permits exhausted — rejection thrown5.54 μs64.31 μs1.3 KB39.5 KB11× faster
Permits exhausted — rejection via ExecuteOutcomeAsync99.2 ns42.09 μs136 B33.6 KB408× faster
Concurrency limit — uncontended149 ns172 ns0 B40 B1.4× faster
WithHooks_Uncontended153 ns—0 B——
Adaptive_Uncontended221 ns—0 B——

Typed result handling​

Retry configured to treat a sentinel result as a failure; the returned value never matches, so this is the per-call cost of judging results.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Typed retry — result judged, no retry135 ns181 ns0 B0 B1.5× faster

Composed pipelines​

How per-call overhead scales with pipeline depth when nothing goes wrong.

ScenarioKevlarPollyKevlar allocatedPolly allocatedKevlar vs Polly
Timeout → Retry → ratio breaker338 ns671 ns0 B48 B1.9× faster
Token bucket → Timeout → Retry → ratio breaker → Concurrency limit487 ns942 ns0 B88 B2.0× faster
TokenBucketRatioFiveStrategyChainSync441 ns964 ns0 B88 B2.2× faster

Environment​

  • AMD EPYC 7763
  • .NET 10.0.14 (10.0.14, 10.0.1426.52326), BenchmarkDotNet 0.15.8
  • Times are medians; allocations are per operation.

Reproduce​

dotnet run -c Release --project benchmarks/Kevlar.Benchmarks -- --filter '*'

As always with microbenchmarks: measure your own workload before optimizing around these numbers. Nanosecond differences matter in tight loops and high-throughput services; they don't matter around a 50 ms network call.