Re: Why are page faults used for safe point polling instead of other signals?

2020-05-30 Thread Gil Tene
The fast-path overhead in this polling scheme (calling code at a specific memory location and returning from it, relying on remapping of the page the code us in to change its behavior from do-nothing to take-safepoint) is much higher than the currently-popular polling schemes of loading from a

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-30 Thread Gil Tene
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

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-29 Thread Alex Blewitt
> On 29 May 2020, at 17:46, 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. Under what basis are you making

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-29 Thread Steven Stewart-Gallus
Behold! I don't think this actually safely works though on x86 at least. Pretty sure they use the virtual address for instruction caching and debuggers have to do synchronisation when modifying from a different address space. oh well. On Friday, May 29, 2020 at 9:46:38 AM UTC-7, Steven Stewart

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-29 Thread Steven Stewart-Gallus
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 sh

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-18 Thread Steven Stewart-Gallus
Hi What I guess I sort of mean is that I'm looking for more papers like this one https://dl.acm.org/doi/10.1145/2887746.2754187 . I guess I did not explain myself well. I'm well aware of the theory behind choosing a simple read but the key word is "empirically chosen". Are there public benchmarks

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-18 Thread Gil Tene
This is an evolving and ever-explored field... The "current" (and in typically used in production 8 and 11) versions of OpenJDK and HotSpot performs safepoint as an all-or-nothing, Stop-The-World (STW) event. Since the frequency of STW pauses will generally tend to be low (for obvious reasons,

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-18 Thread Ben Evans
In Hotspot there's also JEP 312 - http://openjdk.java.net/jeps/312 - as of Java 10 which might be useful to you, depending on your use case. Anyone familiar enough with J9 to comment on how that works? I see to remember from talking to Gil that the approach Zing takes is also interesting, but that

Re: Why are page faults used for safe point polling instead of other signals?

2020-05-18 Thread Alex Blewitt
There’s a couple of overlapping questions here. I hope I can answer them, if not necessarily the right order. Reads are used rather than writes because reads don’t incur cross-CPU cache invalidations. If threads were writing to a page, then cache invalidation traffic would be sent between CPUs,

Why are page faults used for safe point polling instead of other signals?

2020-05-17 Thread Steven Stewart-Gallus
Hi As I understand it most VMs poll for safepoints by using memory management tricks to page fault polling threads. A page is set aside to read from and whenever a safepoint is desired the page is set to be unreadable. But can't a number of other hardware traps be used instead https://wiki.osde