We've got an ASP.NET website (Nancy) which uses async/await, and Shouldly for assertions.
We're seeing some slow requests (via AppInsights), and the info shows the thread being 'blocked' on ShouldAllBe
, specifically the Compile call.
Here's an example from AppInsights Profiler ETL trace:
In the screenshot above, 3.2 seconds was spend blocked waiting for ShouldAllBe
to complete. (reference on what BLOCKED_TIME
means: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-profiler)
The GetItemsFromRedisAsync
method looks like this:
keys.ShouldNotBeEmpty();
keys.ShouldAllBe(cacheKey => !string.IsNullOrWhiteSpace(cacheKey));
// go to redis
So, it's like the LINQ compilation is getting stuck/blocked? I couldn't replicate with a simple console app thrashing with 1000's of strings, but wondering if anyone here can provide some further guidance?
What's also really confusing me is why it's showing BLOCKED_TIME
?
From the AppInsights docs:
BLOCKED_TIME indicates the code is waiting for another resource to be available, such as waiting for a synchronization object, waiting for a thread to be available, or waiting for a request to finish.
How can any of those be possible for a LINQ evaluation?