2 ms·
This did not improve performance, it was just an unnecessary hack. The authors agree, as they removed it realizing it was not an optimization. UNIX signals are
by arghwhat 3y ago
This did not improve performance, it was just an unnecessary hack. The authors agree, as they removed it realizing it was not an optimization.
UNIX signals are in no way or form direct translations of hardware CPU traps. The kernel handles hardware traps, which may or may not lead to UNIX signals. Heck, with userfaultfd, a different userspace process could be handling, or injecting, the fault! Not to mention VMs, where the the guest userspace is very far away from any real hardware traps.
There are basically two classes of UNIX signals: Signals that indicate that you might need to take some action (SIGTERM, SIGALRM, SIGUSR1, ...), and signals that indicate that your process did something illegal (SIGILL, SIGSEGV, SIGFP, ...). There is a very, very limited number of cases where handling these errors make sense, and trying to be "clever" to make (faulty and ill-advised) performance optimizations is not one of them.
- quotemstr 3y agoPlease, knock it off with the value judgements. "Ill-advised" according to whom? You? Why should your opinion prevail? > This did not improve performance, it was just an unnecessary hack Well, the Android VM certainly uses a signal mechanism for safepoints and stack overflow checking, for a reason (https://android.googlesource.com/platform/art/+/master/runtime/fault_handler.cc#299 https://android.googlesource.com/platform/art/+/master/runti...) (both latency and code size), so don't sit there and tell me that the VM running the world's most popular OS is pessimizing itself pointlessly. > The kernel handles hardware traps, which may or may not lead to UNIX signals. Not all traps result in signals, and not all signals are traps. Nevertheless, the POSIX signals API is the means through which Unix OSes provide user programs the ability to interact with CPU traps. (Windows does the same thing, morally, with SEH and vectored exception handling --- https://learn.microsoft.com/en-us/windows/win32/debug/vectored-exception-handling https://learn.microsoft.com/en-us/windows/win32/debug/vector...). Any decent OS should provide applications with the tools they need to make full use of the underlying hardware. All these anti-signals people are just arguing that programs be bigger and slower, because they can't make full use of all the hardware features of the system, out of, ultimately, an aesthetic objection to signal handling.
- arghwhat 3y ago> Please, knock it off with the value judgements. "Ill-advised" according to whom? You? Why should your opinion prevail? Ill-advised as per the authors decision to remove said hack as it brought none of the intended benefits. Or are you suggesting that your opinion is more valuable than the authors whose code we're discussing? Be careful with fallacies suggesting only one side of an argument is based on opinions. :)
- quotemstr 3y agoThe actual text from https://bugs.java.com/bugdatabase/view_bug?bug_id=8327860 https://bugs.java.com/bugdatabase/view_bug?bug_id=8327860 says this: > We have been working on a patch that switches the jit protection mode to EXEC around these potential faulting memory accesses. Yes, they're changing one aspect of signal handler use to work around this problem. They're not stopping the use of signal handlers in general. Hotspot continues to use signals for efficiency in general. See https://github.com/openjdk/jdk/blob/9059727df135dc90311bd476124f090b5766092b/src/hotspot/os/posix/signals_posix.cpp#L557 https://github.com/openjdk/jdk/blob/9059727df135dc90311bd476... > Be careful with fallacies suggesting only one side of an argument is based on opinions. :) The wonderful thing about choosing not to care about facts is having whatever opinions you want.
- arghwhat 3y ago> Yes, they're changing one aspect of signal handler use to work around this problem. They're not stopping the use of signal handlers in general. Hotspot continues to use signals for efficiency in general. See https://github.com/openjdk/jdk/blob/9059727df135dc90311bd476 https://github.com/openjdk/jdk/blob/9059727df135dc90311bd476... This whole thread is about SIGSEGV, and specifically their SIGSEGV handling. However, catching normal signals is not about efficiency. Some of their exception handling is still odd: There is no reason for a program that receives SIGILL to ever attempt continuing. But others is fine, like catching SIGFPE to just forward an exception to the calling code. (Sure, you could construct an argument to say that this is for efficiency if you considered the alternative to be implementing floating point in software so that all exceptions exist in user-space, but hardware floating point is the norm and such alternative would be wholly unreasonable.) > The wonderful thing about choosing not to care about facts is having whatever opinions you want. I appreciate the irony of you making such statement, proudly thinking that your opinion equals fact, and therefore any other opinion is not. This discussion is nothing but subjective opinion vs. subjective opinion. Facts are (hopefully, as I can only speak for myself) inputs to both our opinions, but no opinion about "good" or "bad", "nasty" or not can ever be objective. Objective code quality does not exist.