Skip to main content

Adaptative Concurrency Limiter Test Report

Benchmark

Below, it is possible to see a benchmark analysis of the concurrency control mechanism. For this test multiple scenarios were created:

  • Limiter_Default: Directly tests the AdaptiveConcurrencyLimiter with default priority;

  • Limiter_RandomPriority: Directly tests the AdaptiveConcurrencyLimiter with random priorities;

  • LimiterMiddleware_Default: Tests the ConcurrencyLimiterMiddleware that uses the AdaptiveConcurrencyLimiter with Http Requests context with default priority;

  • LimiterMiddleware_RandomPriority: Tests the ConcurrencyLimiterMiddleware that uses the AdaptiveConcurrencyLimiter with Http Requests context with random priorities;

  • TaskQueueWith1000Items_EnqueueFixedPriority: Tests the TaskQueue.Enqueue pre-loaded with 1000 items and a default priority;

  • TaskQueueEmpty_EnqueueRandomPriority: Tests the TaskQueue.Enqueue with no elements;

  • TaskQueueWith1000Items_EnqueueRandomPriority: Tests the TaskQueue.Enqueue pre-loaded with 1000 items and random priorities;

  • TaskQueueWith1000Items_Dequeue: Tests the TaskQueue.Dequeue pre-loaded with 1000 items;

  • TaskQueue_EnqueueNewItem_LimitReached: Tests the TaskQueue.Enqueue pre-loaded with 1000 items and the queue limit reached;

Limiter

BenchmarkDotNet=v0.13.4, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
Intel Core i7-10610U CPU 1.80GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.103
[Host] : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-VLMTWN : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2

IterationCount=10
MethodMeanErrorStdDevMinMaxRankCompleted Work ItemsLock ContentionsGen0Allocated
Limiter_Default354.4 ns6.22 ns3.25 ns349.2 ns358.4 ns10.0000-0.1450608 B
Limiter_RandomPriority366.3 ns4.82 ns2.52 ns363.6 ns369.6 ns20.0000-0.1450608 B
LimiterMiddleware_Default436.6 ns28.55 ns16.99 ns416.7 ns471.4 ns30.0000-0.1855776 B
LimiterMiddleware_RandomPriority468.7 ns6.55 ns3.90 ns463.7 ns475.3 ns40.0000-0.2027848 B

TaskQueue

BenchmarkDotNet=v0.13.4, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
Intel Core i7-10610U CPU 1.80GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.103
[Host] : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-THBOTE : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2

InvocationCount=1 IterationCount=10 UnrollFactor=1

MethodMeanErrorStdDevMinMaxRankCompleted Work ItemsLock ContentionsAllocated
TaskQueueWith1000Items_EnqueueFixedPriority11.311 μs3.8278 μs2.2779 μs6.800 μs14.800 μs4--896 B
TaskQueueEmpty_EnqueueRandomPriority6.700 μs3.8089 μs2.2666 μs4.800 μs11.800 μs2--896 B
TaskQueueWith1000Items_EnqueueRandomPriority3.650 μs0.3540 μs0.1852 μs3.400 μs4.000 μs1--896 B
TaskQueueWith1000Items_Dequeue5.500 μs1.0912 μs0.5707 μs4.600 μs6.400 μs2--704 B
TaskQueue_EnqueueNewItem_LimitReached8.111 μs2.2848 μs1.3596 μs7.000 μs10.500 μs3--1144 B

Conclusion

In all the scenarios the time added to the execution pipeline is very small and the impact caused by the limiter and task queue can be ignored.