4 ms·
The gist is that C++ coroutines’ context switches are cheaper than cache misses. Hence, if you can write coroutines that fill the caches more intelligently than
by stingraycharles 6y ago
The gist is that C++ coroutines’ context switches are cheaper than cache misses. Hence, if you can write coroutines that fill the caches more intelligently than that the hardware prefetcher can do (because you know more about what your application is trying to achieve), you can outperform the hardware prefetcher. You write a whole lot of coroutines that fill caches, suspend them while they do it, and once they are resumed, you can assume that the caches are now filled with your data and have just achieved better efficiency.
Hope this was a clear enough explanation, and someone correct me if I’m wrong.
- qppo 6y agoNot an expert here but I think there's a non trivial detail to your gist, which is that (user space) context switches can be faster than cache misses, and you can design a scheduler that knows enough about its coroutines to switch to a new context with a low probability of a cache miss.