I was trying out the Firefox Profiler, and it is reporting that while playing a video on Youtube, that a lot of CPU time is spent on the function
SleepConditionVariableSRW. So I’m asking if this is a real thing, or just an illusion.
Context switching is really expensive. It costs 15000 CPU cycles to wake up a thread. So there needs to be significantly more than 15000 CPU cycles worth of work before it’s a good idea to wake up threads to help out with tasks. And if a thread completes a task, it needs another task quickly. If it doesn’t get another task quickly, it must spinwait or go to sleep again.
But I also heard that Firefox puts all work into a separate restricted process. Is the Firefox Profiler able to see what’s going on in there? If it can’t, then it would make sense that all the time is spent in the main process waiting for the secondary process to finish.
I’m just a bit confused, because Firefox seems to always have very high CPU usage while using Youtube or Twitch, especially when overlaying HTML over videos.