just brew it! wrote:
10 microseconds sounds pretty high; that may be worst-case, or maybe for a much older generation of processors?
Aside from data needed by the process itself needing to get pulled back into cache, I imagine the switching time could also vary a fair bit based on whether the internal register state data for the process being switched to is still in cache, or needs to be fetched from DRAM.
And I made another mistake in my math. Assuming a 4GHz processor (not 1 GHz processor), the actual context switch speeds are 0.04 microseconds (AMD) and 0.1 microseconds (Intel).
In any case, the numbers I was associated with probably were some kind of "worst case scenario", involving saving AVX registers to maybe DDR4 RAM (not enough room for cache), etc. etc. AVX-256 bit registers x 16 == 512 bytes of state, which needs to fetch/store 8x cache-lines. Hmm, that's still probably sub-1 microsecond even in the worst case.
I guess my memory is just wrong. Seems like 0.2 microseconds (200 nanoseconds) is a better estimate for worst-case context switch. It must have been older hardware or something that I'm (mis)remembering about.