-
Enhancement
-
Resolution: Fixed
-
P4
-
17, 21, 22, 23
-
b04
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8336835 | 23.0.1 | Xiaolong Peng | P4 | Resolved | Fixed | b04 |
JDK-8336922 | 21.0.5 | Xiaolong Peng | P4 | Resolved | Fixed | b01 |
JDK-8340315 | 17.0.14 | Xiaolong Peng | P4 | Resolved | Fixed | b01 |
On loaded systems, we would need to wait for threads to roll over the spinwait before they can block. For the overload factor of 100 (e.g. 6400 thread on 64-core machine), this would mean 4ms of additional TTSP.
We can probably mitigate this by spinning for shorter duration.
Sample test:
```
public class Alloc {
static final int THREADS = 1024;
static final Object[] sinks = new Object[64*THREADS];
static volatile boolean start;
static volatile boolean stop;
public static void main(String... args) throws Throwable {
for (int t = 0; t < THREADS; t++) {
int ft = t;
new Thread(() -> work(ft * 64)).start();
}
start = true;
Thread.sleep(10_000);
stop = true;
}
public static void work(int idx) {
while (!start) { Thread.onSpinWait(); }
while (!stop) {
sinks[idx] = new byte[128];
}
}
}
```
Run it like this and observe TTSP times:
```
java -Xms256m -Xmx256m -XX:+UseShenandoahGC -XX:-UseTLAB -Xlog:gc -Xlog:safepoint Alloc.java
```
Things to consider:
1) Do we need to check for `SafepointSynchronize::is_synchronizing()` to exit spinning early when safepoint is pending?
2) Does `ThreadBlockInVM` do suspension correctly?
3) Do we need to unpark from sleep faster (somehow?) when safepoint is over? That may involve switching to mutex of some sort.
Note from Roman:
I have a feeling that #1 and #2 can both be achieved by simply adding 'true' to the ThreadBlockInVM constructor invocation.
- backported by
-
JDK-8336835 Shenandoah: Reconsider spinning duration in ShenandoahLock
- Resolved
-
JDK-8336922 Shenandoah: Reconsider spinning duration in ShenandoahLock
- Resolved
-
JDK-8340315 Shenandoah: Reconsider spinning duration in ShenandoahLock
- Resolved
- relates to
-
JDK-8332083 Shenandoah: Reduce contention on Global Heap Lock
- New
-
JDK-8325587 Shenandoah: ShenandoahLock should allow blocking in VM
- Resolved
-
JDK-8335904 Fix invalid comment in ShenandoahLock
- Resolved
- links to
-
Commit openjdk/jdk/817edcb6
-
Commit(master) openjdk/jdk17u-dev/4f08bcd2
-
Commit(master) openjdk/jdk21u-dev/2c981bc9
-
Commit(master) openjdk/jdk23u/9805cbbd
-
Review openjdk/jdk/19570
-
Review(master) openjdk/jdk17u-dev/2868
-
Review(master) openjdk/jdk21u-dev/850
-
Review(master) openjdk/jdk23u/27