I'm getting intermittent spikes in my profiler around the call to QueueUserWorkItem(). I queue roughly 20 jobs every second. Each job is roughly identical in terms of complexity. 95% of the jobs spend less than 0.01ms in the call to QueueUserWorkItem. But every few seconds, seemingly at random, a job will take from 20-60ms!
I'm trying to build a smooth simulation and just queuing my background tasks is causes serious hitches in my framerate.
This is not the time it takes for the job to actually FINISH, this is time spent on simply QUEUEING the job. Which I would expect should take virtually no time at all, so this is very frustrating.
foreach ( Job j in jobs_to_process )
{
Job current_job = j;
if ( !current_job.queued )
{
current_job.queued = true;
Profiler.BeginSample("QueueWorkItem");
ThreadPool.UnsafeQueueUserWorkItem( current_job.DoCalculation, null );
Profiler.EndSample();
}
}
//now I remove queued items from jobs_to_process, move them to jobs_in_progress list
Things I've tried:
Try with the --server flag when running mono (only compatible with mono master, as it was committed recently).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With