5 ms·
The Twitter discussion mentions this: > We can forcefully preempt virtual threads at any safepoint poll point What is a "safepoint poll point"? A sleep call?
by ferdowsi 4y ago
The Twitter discussion mentions this:
> We can forcefully preempt virtual threads at any safepoint poll point
What is a "safepoint poll point"? A sleep call?
- papercrane 4y agoA safepoint in the JVM is a state where all the objects on the heap are consistent and the GC roots are known. These safe points are important for the GC to able to safely work. A safepoint poll points are points in a threads execution where it's able to go into a safepoint and transfer control to the JVM so it polls to see if it should. https://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html https://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary... https://shipilev.net/jvm/anatomy-quarks/22-safepoint-polls/ https://shipilev.net/jvm/anatomy-quarks/22-safepoint-polls/
- native_samples 4y agoNo, safepoints are added to your code by the JVM automatically. When bytecode is being interpreted, every bytecode instruction has a safepoint after it. In compiled code polls are scattered thoughout the code, for example on method entries and loop back edges (so the comment above about needing to add code in tight loops to help the GC is wrong).
- papercrane 4y ago> so the comment above about needing to add code in tight loops to help the GC is wrong This is something where the answer is "it depends". Hotspot will omit the safe point poll in counted loops since it knows those loops will terminate.