Revisit use of YieldProcessor, Sleep(0) may be more appropriate
Categories
(Core :: IPC: MSCOM, task)
Tracking
()
People
(Reporter: mozbugz, Unassigned)
References
Details
While filing bug 1687203 (Profiler using YieldProcessor to wait a short time), I noticed that YieldProcessor is also used in SpinEvent::Wait.
See bug 1687203 for details, but the main point is that YieldProcessor is quite low level and may not really help, while Sleep(0) works with the OS to reschedule threads to do useful work (maybe at a risk of overshooting the delay, but I'm not sure).
Anyway, someone in IPC land may want to look into this... Happy to share notes.
| Reporter | ||
Comment 1•5 years ago
|
||
But then... YieldProcessor presumably generates a "pause" instruction, which Intel documents as:
Provide a hint to the processor that the code sequence is a spin-wait loop. This can help improve the performance and power consumption of spin-wait loops.
So maybe YieldProcessor is in fact the best choice here, since this loop is waiting for mDone to become true? 🤔
(Similar thought as I had in bug 1687203 comment 2, except that in the profiler loop, we're only waiting for some time to elapse, not for a variable to change very soon.)
So, dear IPC maintainer, feel free to close this bug as INVALID if you're satisfied YieldProcessor is the right choice here.
Updated•5 years ago
|
Updated•1 year ago
|
Description
•