Ok. So I downloaded and ran dotTrace. I am new to the tool so forgive my obvious question. I see the a lot of time is spent in wait mode… but not sure why that would drive CPU usage?
WaitAny method first uses a spin lock before transitioning into the kernel wait, so theoretically it can cause some cycles to be burnt on a busy wait. However in practice this will have an effect only if we are constantly calling the
WaitAny method again and again. To avoid such a behavior, the
AutoResetEvent is used in Hangfire.
Repeated calls may also appear, when a lot of jobs are added to the queue, however in this case there will be a lot of jobs to be processed anyway.