HotSpot used to actually safepoint by patching the running code of threads, at some point ahead of where you suspended them. The notion was that this lets you completely avoid any polling instructions and Keeps the fast path as fast as possible. HotSpot gave up on doing this almost 20 years ago.because of a myriad of annoying tail bugs, including ones that had to do with edge cases around how OSs deal with suspension, signal delivery, etc., and around the delicate challenges in patching running code safely and atomically. It’s not that such a scheme couldn’t be made to work (it actually ran in production versions for a while), it’s that it had too much hair on it to keep going, and ultimately was not worth it given the very low cost of actual polling instructions on modern OOO cpus.
On Friday, May 29, 2020 at 9:46:38 AM UTC-7, Steven Stewart-Gallus wrote: > > Okay I have an idea. > I can't shake the idea you could do fun tricks with thread local > executable pages. > > The theoretically fastest way of safepoint polling is inserting a trap > instruction. But icache overheads dominate. If the icache is based on > physical addresses and not virtual ones then it should be possible to remap > the page without doing icache synchronization. > You should be able to have very fast safepoints by remapping the page. > > But I'm not sure there's a fast way to do a call/return from thread local > storage. And a call/return from a constant page still might not be faster > than just a load. > > TLDR: > Limited self modifying code without icache syncing stuff could be possible > with memory management tricks as long as the icache and other stuff is > based on physical addresses. > > -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web, visit https://groups.google.com/d/msgid/mechanical-sympathy/05af901a-99fe-49f7-acb3-e8444e38ec1b%40googlegroups.com.
