devexperts / lin-check Goto Github PK
View Code? Open in Web Editor NEWLinearization checker for Java concurrent programs
License: Mozilla Public License 2.0
Linearization checker for Java concurrent programs
License: Mozilla Public License 2.0
Currently, the way runner is invoker via classname does not let itself easily to parametrization. Consider a datastructure with two modes of operation and we want to run lin-check with it without copy-and-paste:
class XxxTest(val mode: Boolean) {
lateinit var ds: DataStructure
@Reset { ds = DataStructure(mode) }
// operations here
@Test fun test() {
val optinos = ...
LinChecker.check(XxxTest::class.java, options)
}
}
This above code does not work, because there is not default constructor in XxxTest
. If you extract common parts into a base class and make two inherited classes for each mode, then it does not work either, because lincheck cannot find @Reset
method declared in a parent.
Some supported way of running parametrized tests is needed.
LinkChecker.checkImpl
method generates all possible executions and then uses executeActors(linEx)
on each one. It is very slow, because it does TestThreadExecutionGenerator.create
every time, defining new classes for each execution (instead of defining them just once and reusing). Because of this lincheck does not really scale to complex tests. In my case it "hangs" trying to produce executions for this schenario with four threads (4/4/4/2 operations):
Actors per thread:
[removeFirst()[w], removeFirst()[w], addLastIfPrevDiff(2)[w], removeFirstOrPeekIf(1)[w]]
[removeFirst()[w], addFirstIfEmpty(1)[w], addFirstIfEmpty(2)[w], addFirstIfEmpty(3)[w]]
[addLast(1)[w], addLastIfPrevDiff(3)[w], addFirst(2)[w], addLast(1)[w]]
[removeFirstOrPeekIf(2)[w], removeFirst()[w]]
`@StressCTest(iterations = 300, actorsPerThread = {"1:3", "1:3", "1:3"})
@param(name = "value", gen = IntGen.class)
public class LinkedList1 {
private List<Integer> list;
@Reset
public void reset() {
list = new LinkedList<>();
}
@Operation(params = {"value"})
public void add(Integer value) {
list.add(value);
}
@Operation(params = {"value"})
public void remove(Integer value) {
list.remove(value);
}
@Test
public void test() {
LinChecker.check(LinkedList1.class);
}
}`
This test is always true for Array & Linked list, it is okay, because they are not concurrent ?
Can you provide incorrect list or test for that ?
Some useful data structures, like fast MPSC queues that are used for scheduling, are not linearizable, but give weaker guarantees like quiescent consistency in particular. It seems straightforward to extend lin-check methodology to support testing for quiescent consistency, too.
Note, that the existing framework for custom verifiers is not flexible enough to support that. It only support pluggable verification stage, while testing for quiescent consistency requires run a larger set of transpositions on original operation (all of the shall be tested without regard for program order).
Actual: 404
Expected: Issues page
If you run for a lot of iterations you end up with:
java.lang.OutOfMemoryError: Compressed class space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at com.devexperts.dxlab.lincheck.TestThreadExecutionGenerator$ExecutionClassLoader.define(TestThreadExecutionGenerator.java:266)
at com.devexperts.dxlab.lincheck.TestThreadExecutionGenerator$ExecutionClassLoader.access$100(TestThreadExecutionGenerator.java:264)
at com.devexperts.dxlab.lincheck.TestThreadExecutionGenerator.create(TestThreadExecutionGenerator.java:92)
at com.devexperts.dxlab.lincheck.LinChecker.executeActors(LinChecker.java:193)
at com.devexperts.dxlab.lincheck.LinChecker.lambda$checkImpl$4(LinChecker.java:140)
at com.devexperts.dxlab.lincheck.LinChecker$$Lambda$21/457233904.apply(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.devexperts.dxlab.lincheck.LinChecker.checkImpl(LinChecker.java:150)
at com.devexperts.dxlab.lincheck.LinChecker.lambda$check$0(LinChecker.java:69)
at com.devexperts.dxlab.lincheck.LinChecker$$Lambda$7/977993101.accept(Unknown Source)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at com.devexperts.dxlab.lincheck.LinChecker.check(LinChecker.java:67)
at com.devexperts.dxlab.lincheck.LinChecker.check(LinChecker.java:60)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.