3 ms·
Memory protection games just don't scale. You're modifying global structures, resulting in tons of contention. That's also why compacting GCs prefer to use card
by cyberax 1y ago
Memory protection games just don't scale. You're modifying global structures, resulting in tons of contention. That's also why compacting GCs prefer to use card marking rather than mprotect.
About 2. - that's exactly what I meant. The downside is that now you have to write a full x86 emulator, maybe including SIMD instructions. Good luck.
And that's also what I want to try to avoid. Imagine generating a copy of the innermost loops, with the nearest backbranch replaced with a jump into the GC code. Then from the signal handler you just need to find the offset between the current instruction pointer and the mirror copy, adjust the pointer, and exit from the signal handler.
- pizlonator 1y ago> Memory protection games just don't scale. You're modifying global structures, resulting in tons of contention. That's also why compacting GCs prefer to use card marking rather than mprotect. I’m describing what production JVMs do. They do it because it’s a speedup for them. Like, those compacting GCs that you’re saying use card marking are using page faults for safe points more often than not. It’s true that page protection games don’t result in speedups for generational store barriers. A safe point is not that.
- cyberax 1y agoI believe, Oracle JVM uses polling? This is the class responsible for safepoints: https://github.com/openjdk/jdk/blob/4b544f93ad0e2beae4c80e060cae727d143151ac/src/hotspot/share/runtime/safepointMechanism.hpp#L38 https://github.com/openjdk/jdk/blob/4b544f93ad0e2beae4c80e06... And this is one of the implementations: https://github.com/openjdk/jdk/blob/4b544f93ad0e2beae4c80e060cae727d143151ac/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp#L3773 https://github.com/openjdk/jdk/blob/4b544f93ad0e2beae4c80e06... The arming code: https://github.com/openjdk/jdk/blob/4b544f93ad0e2beae4c80e060cae727d143151ac/src/hotspot/share/runtime/safepointMechanism.cpp#L94 https://github.com/openjdk/jdk/blob/4b544f93ad0e2beae4c80e06... I might be missing something, but I'd be terribly surprised if VM games are worth it.
- pizlonator 1y agoThat JVM totally uses the page protection trick. Look at the code that talks about polling page.
- cyberax 1y agoD'oh. I don't know how I missed it. It's right there around the line 69. Nice. Well, I'm definitely surprised it works.