Skip to content

Synchronous Task.WaitAll() in LoqQueue causes async/await performance problems in .NET Core #84

@AdamEssenmacher

Description

@AdamEssenmacher

I have an Azure function app that's performance-critical. After instrumenting it with NLog and a StackifyTarget with an AsyncWrapper, I was perplexed to be observing the following:
stackify logging

As you can see, a request that I would have expected to execute in 20ms instead took 775ms (39x longer!) due to what looks like blocking code from the StackifyTarget. Thinking perhaps the NLog AsyncWrapper wasn't behaving as it should, I did some debugging and found that the wrapper itself is behaving as expected.

Digging deeper, I found that the AsyncWrapper is pretty useless when used in conjunction with the StackifyTarget, as the StackifyTarget itself queues messages up for "asynchronous" uploading using System.Threading.Timer.

This would be great if the timer function was actually asynchronous. It's not.

My code, which uses async/await code for all I/O operations, is now sharing a threadpool with a synchronous, I/O-bound resource hog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions