On Saturday, March 30, 2019 at 10:17:15 AM UTC-7, Steven Stewart-Gallus wrote: > > I feel like this is just a bug in the JDK that should be patched. >
And how would you "patch" it? Without the result being sucky performance, that is? The tension is between the performance of mapped byte buffer access, and the wish to avoid being caught in a page fault while not at a safepoint. You can do one or the other "easily": either be at a safepoint on all buffer accesses, or don't. Being at a safepoint in e.g. every call to ByteBuffer.get() [in the actual memory accessing code that is susceptible to page faults] would certainly prevent the TTSP-due-to-page-fault problems. But it would also dramatically reduce the performance of loops with such access in them. Not only because of the need to poll for safepoint conditions on every access but [mostly] because many compiler optimizations are "hard" to do across safepoint opportunities. > Couldn't this all be solved by replacing UNSAFE.copyMemory with a call to > a different method that isn't a HotSpot intrinsic? > > > https://hg.openjdk.java.net/jdk/jdk/file/235883996bc7/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template#l313 > > <https://www.google.com/url?q=https%3A%2F%2Fhg.openjdk.java.net%2Fjdk%2Fjdk%2Ffile%2F235883996bc7%2Fsrc%2Fjava.base%2Fshare%2Fclasses%2Fjava%2Fnio%2FDirect-X-Buffer.java.template%23l313&sa=D&sntz=1&usg=AFQjCNGHP2codNwATOrWvClher6ew3RlmA> > > Interestingly I don't believe that copySwapMemory is an intrinsic so an > ugly kludge might be to use a nonnative byte order deliberately. > Counting on things not being intrinsified (or treated as leaf functions that don't need safepoints) is a dangerous practice, since anything in the jdk may become intrinsifed or otherwise optimized tomorrow. But specifcially to the above, copySwapMemory (via copySwapMemory0) is already treated as a known leaf method (http://hg.openjdk.java.net/jdk/jdk/file/235883996bc7/src/hotspot/share/prims/unsafe.cpp#l1095), which (among other things) means that [unlike generic JNI calls] no safepoints will be taken on calling it. -- 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]. For more options, visit https://groups.google.com/d/optout.
