kotlinx-lincheck icon indicating copy to clipboard operation
kotlinx-lincheck copied to clipboard

Merge consecutive spin-loop blocks and remove redundant thread switches

Open eupp opened this issue 9 months ago • 0 comments

The trace can contain several consecutive thread switches to the blocks of the same spin-loop.

Example:

|         /* The following events repeat infinitely: */                                |
|     ┌╶> state ➜ 0 at FutureTask.awaitDone(FutureTask.java:406)                       |
|     |   LockSupport.park(FutureTask#1) at FutureTask.awaitDone(FutureTask.java:447)  |
|     └╶╶ switch (reason: active lock detected)                                        |
|                                                                                      |
|                                                                                      |
|                                                                                      |
|                                                                                      |
|         /* The following events repeat infinitely: */                                |
|     ┌╶> state ➜ 0 at FutureTask.awaitDone(FutureTask.java:406)                       |
|     |   LockSupport.park(FutureTask#1) at FutureTask.awaitDone(FutureTask.java:447)  |
|     └╶╶ switch (reason: active lock detected)                                        |

https://github.com/JetBrains/lincheck/blob/f0b6b224c88b82b4fe5b7ac443abb94df03c58eb/src/jvm/test/resources/expected_logs/run_concurrent_test/thread_pool/thread_pool_jdk17.txt#L106

We need to fix this by merge several consecutive spin-loop blocks, and do not show redundant thread switches.

eupp avatar Mar 03 '25 19:03 eupp