0

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: image

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?

RPM1984
  • 72,246
  • 58
  • 225
  • 350
  • You really need a [mcve] for us to help here. Right now you're a million times better poised to solve this than us because you have runable code. – Enigmativity Aug 24 '17 at 00:54
  • 1
    ~ 3+ seconds for a Linq query, why not depending on what you are trying to do there. Normally I have seen repetitive `ToList() ` or similar calls leads to time wastage, as they do new data structure allocation internally and thus not use the deferred execution effectively, just check and ensure that something like ToList(), is not done till the very end, when you need data in the memory – Mrinal Kamboj Aug 24 '17 at 07:36
  • @Enigmativity - I haven't got a verifiable example. Like I said, I tried to reproduce in a console app but didn't have much luck. I believe what I've provided (the problem method, ShouldAllBe which is open source) is pretty minimal. What else can I do? – RPM1984 Aug 24 '17 at 21:19
  • @Mrinal Kamboj- yeah, my gut instinct was telling me it's a deferred execution problem too. But like I said, I tried with a console app with 1000s of strings and couldn't replicate. I'm a bit stumped on what to try next... other than simply removing the method call altogether. :/ – RPM1984 Aug 24 '17 at 21:22

0 Answers0