-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spin locks detection enhancements #228
Conversation
… caused by multiple spin cycle iterations.
…s' into spin-locks-detection-enhancements
…on-enhancements # Conflicts: # src/jvm/main/org/jetbrains/kotlinx/lincheck/runner/InvocationResult.kt # src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/InterleavingSequenceTrackableSet.kt # src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/ManagedStrategy.kt # src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/modelchecking/ModelCheckingStrategy.kt # src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/SpinlockEventsCutTests.kt # src/jvm/test/resources/expected_logs/switch_in_the_middle_of_spin_cycle_causes_error.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an intermediate review. I need to switch to java agents now; after that, I'll finish the review.
@@ -52,6 +52,7 @@ kotlin { | |||
api("org.ow2.asm:asm-commons:$asmVersion") | |||
api("org.ow2.asm:asm-util:$asmVersion") | |||
api("org.reflections:reflections:$reflectionsVersion") | |||
api("net.sf.trove4j:trove4j:3.0.3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please repackage it to org.jetbrains.kotlinx.lincheck
|
||
package org.jetbrains.kotlinx.lincheck.strategy.managed; | ||
|
||
public class TrackMethodsFlagHolder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrite to Kotlin
|
||
package org.jetbrains.kotlinx.lincheck.strategy.managed; | ||
|
||
public class TrackMethodsFlagHolder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use it only when detecting spin locks?
@@ -84,7 +84,8 @@ private static boolean doNotTransform(String className) { | |||
className.equals(kotlinx.coroutines.CoroutineContextKt.class.getName()) || | |||
className.equals(kotlinx.coroutines.CancellableContinuation.class.getName()) || | |||
className.equals(kotlinx.coroutines.CoroutineExceptionHandler.class.getName()) || | |||
className.equals(kotlinx.coroutines.CoroutineDispatcher.class.getName()); | |||
className.equals(kotlinx.coroutines.CoroutineDispatcher.class.getName()) || | |||
className.equals(TrackMethodsFlagHolder.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to other Lincheck classes, it should not be transformed by default
@@ -252,6 +260,7 @@ internal class ModelCheckingStrategy( | |||
} | |||
|
|||
fun rollbackAfterSpinCycleFound() { | |||
lastNotInitializedNode = initialLastNotInitializedNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change related to another bug?
): InterleavingHistoryNode { | ||
check(executions >= executionsBeforeCycle) | ||
check(executions >= executionsBeforeCycle) { "?" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace "?" with a meaningful message
@@ -241,7 +256,8 @@ internal class InterleavingSequenceTrackableSet { | |||
fun mergeBranch(newChain: List<InterleavingHistoryNode>, startIndex: Int, executionsCountedEarlier: Int) { | |||
if (startIndex > newChain.lastIndex) return | |||
val firstNewNode = newChain[startIndex] | |||
val firstNewNodeExecutions = (firstNewNode.executions + firstNewNode.spinCyclePeriod) - executionsCountedEarlier | |||
val firstNewNodeExecutions = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the formatting
@@ -263,7 +279,8 @@ internal class InterleavingSequenceTrackableSet { | |||
transitions = transitions, | |||
cyclePeriod = cyclePeriod, | |||
cycleOccurred = cycleOccurred, | |||
cycleLocationsHash = cycleLocationsHash | |||
cycleLocationsHash = cycleLocationsHash, | |||
executionsBeforeSpinCycleWithAdditionalEvents = executionsBeforeSpinCycleWithAdditionalEvents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shorten the parameter name
@@ -424,6 +444,8 @@ internal class InterleavingSequenceTrackableSet { | |||
it.cycleOccurred && executionsCount == it.executions | |||
} ?: false | |||
|
|||
val executionsBeforeSpinCycleWithAdditionalEvents: Int get() = currentNode!!.executionsBeforeSpinCycleWithAdditionalEvents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document
} else CycleInfo( | ||
minLastPositionNotRelatedToCycle + 1, | ||
targetCycleLength | ||
) // number of prefix elements with first cycle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment in the correct place?
The changes will be delivered under #331 |
Closes #219 #218 and adds recursive spin-locks support.
Subtasks:
develop
withjavaagent
2d