Commit Graph

648 Commits

Author SHA1 Message Date
Michael Walker
9d2c3cd42e Comment the tricky bits in Test.DejaFu.SCT more 2015-07-21 17:28:28 +01:00
Michael Walker
5649c4d2a7 Use Set instead of [] where it makes sense.
A lot of the places where lists were used, there was an assumed invariant that
there would be no duplicate entries, for some criteria of equality. In some
cases this was enforced by `nub`, in others not. Sets are a much better choice
here, as they actually enforce the invariant, with better complexity for some
operations.
2015-07-21 16:09:47 +01:00
Michael Walker
112a7cd138 Add some instances for NonEmpty 2015-07-21 16:09:11 +01:00
Michael Walker
c786a30448 Fix accidentally recursive binding 2015-07-21 15:30:29 +01:00
Michael Walker
3c1dadffa6 Take advantage of the fact that tagged is sorted 2015-07-21 14:38:00 +01:00
Michael Walker
d4b1ea8bc5 Slightly simplify dependent/dependent' defns 2015-07-21 14:37:36 +01:00
Michael Walker
15f79088c9 Correctly sort prefixes in next 2015-07-21 14:17:16 +01:00
Michael Walker
148cd0a351 Gradually accumulate allThreads in findBacktrack.
Recomputing it every single time is a waste of effort.
2015-07-21 14:16:34 +01:00
Michael Walker
d498ebd355 Extend blocking lookahead.
Adds more information to traces with a new Trace' type, which includes the
*sequence* of actions a thread will perform next, and use that for blocking
lookahead. This allows skipping over things like `_concKnowsAbout`, and so
brings the analysis behaviour of `spawn` in-line with `fork`.

For the test cases, this further reduces the average number of runs to 23.
2015-07-20 18:43:37 +01:00
Michael Walker
338c98b617 Add function to unsafely convert a list to a NonEmpty 2015-07-20 18:42:19 +01:00
Michael Walker
ac48769ea0 Wrap up scheduler state in a record 2015-07-20 16:45:29 +01:00
Michael Walker
c4eefd4849 Avoid decisions which will immediately block.
If a decision will immediately block without changing the global state, then
there is no point in making it: no state will become reachable from it which
isn't reachable through some other option we have available.

This has three parts:

 - When the prefix runs out and the scheduler is making decisions, it filters
   out decisions which will immediately block.

 - When a subtree is being added, it records which decisions will immediately
   block.

 - When backtracking points are being added, it filters out ones in this block
   list.

This optimisation is likely to only be useful when threads are communicating a
lot. For instance, a `parMap id` is totally unaffected by this, but the test
cases drop from an average of 64 runs to 42.
2015-07-20 16:16:46 +01:00
Michael Walker
a0c31f28fa Use Jenkins instead of Travis. 2015-07-19 12:20:18 +01:00
Michael Walker
a8cc4dcab5 Stackify 2015-07-19 04:39:39 +01:00
Michael Walker
aadb27ea1f Implement sleep sets for BPOR.
This further improves performance in all cases, although it's still far worse
on some of the included tests, and I have yet to figure out why.

See also: "Partial-Order Methods for the Verication of Concurrent Systems"
  [Godefroid 1996]
2015-07-17 15:34:52 +01:00
Michael Walker
c12cbcf707 Implement BPOR for SCT, return to listy predicates.
This performs better with "real" code (the Par monad) but surprisingly does far
worse with the included tests! The next thing to do is implement the orthogonal
sleep sets algorithm to cut down on available choices even further and
hopefully correct this issue.

See also: "Bounded Partial-Order Reduction" [Coons, Musuvathi, McKinley 2013]
2015-07-16 22:32:30 +01:00
Michael Walker
23c350c4b1 Fix/ignore hlint warnings 2015-07-10 18:30:34 +01:00
Michael Walker
1c8720a635 Give schedulers one-step lookahead 2015-07-10 18:27:50 +01:00
Michael Walker
89ec649d92 Don't pre-empt guaranteed blocks.
Pre-empting an action which is guaranteed to block is just the same
as letting it block and then inserting a regular non-pre-emptive
context switch.
2015-07-10 15:49:23 +01:00
Michael Walker
2ca7337b01 Avoid scheduling decisions which immediately block (in PB-bounded runner) 2015-07-08 20:06:15 +01:00
Michael Walker
e92d639537 Export ThreadAction' type 2015-07-08 20:05:58 +01:00
Michael Walker
6e01de2e85 Make available the full state of every CVar to SCT runners 2015-07-08 19:15:18 +01:00
Michael Walker
9ca54fea17 Include one-step lookahead in traces 2015-07-08 18:55:30 +01:00
Michael Walker
dab69aebcc Make alwaysTrue2 result less confusing when applied to one schedule only. 2015-07-08 18:20:08 +01:00
Michael Walker
05e2d2f1e4 Fix issue with identifying only-read STM transactions as only creating new CTVars. 2015-07-08 18:18:56 +01:00
Michael Walker
426707f382 Make the stmAtomic test actually test STM atomicity 2015-07-08 18:18:18 +01:00
Michael Walker
8794276a3e Add a Show instance for SCTTrees 2015-07-08 18:17:48 +01:00
Michael Walker
df69f4778c Improve error reporting in alwaysTrue2 (less zealous about short-circuiting 2015-06-24 15:59:54 +01:00
Michael Walker
8944ea97a5 Use schedule bounding as the primary SCT approach.
This allows results to be naturally reported as lazy trees, rather
than as lists representing a tree traversal. This in turn means
that the actual bound can be moved outwards to the testing code, and
not used at all in the runner. Trees let us do nice things with
shrinking and short-circuiting, if we make the (fairly reasonable)
assumption that the children of a buggy result will exhibit the same
bug.

Storing results as trees does complicate the predicate helper
functions somewhat, but I think the clarity gained in the actual
SCT code is well worth it.
2015-06-19 16:50:51 +01:00
Michael Walker
1d085f4ea9 More transformer instances (inc. strict versions) 2015-05-30 01:45:20 +01:00
Michael Walker
d2178c2814 Add some transformer instances 2015-05-29 16:51:51 +01:00
Michael Walker
a93f8202e4 Add dejafus/dejafusIO variants to take a pre-emption bound 2015-05-26 04:14:10 +01:00
Michael Walker
192777c2c9 STMLike type synonyms to shrink type sigs 2015-05-09 19:56:54 +01:00
Michael Walker
0a4bdeee68 Add source-repository to cabal file 2015-03-13 15:01:03 +00:00
Michael Walker
096a1c0651 Switch to MIT license 2015-03-13 14:58:42 +00:00
Michael Walker
fa92d4a050 Don't pre-empt STM transactions which only allocate new variables 2015-03-10 14:18:50 +00:00
Michael Walker
f95ab4122a Report 2 capabilities for test runners, not 4.
The literature sttes that many bugs are found with 2 concurrent
threads, so encouraging even more parallelism is possibly a win in
only a small number of cases, but potentially a huge cost in many.
2015-02-27 21:01:10 +00:00
Michael Walker
3d0a82d915 Lie and return 4 for getNumCapabilities in DejaFu 2015-02-27 01:32:37 +00:00
Michael Walker
6c4015c314 Avoid re-running tests in dejafus. Closes #12. 2015-02-26 21:57:55 +00:00
Michael Walker
9aea975304 Only check runnable threads in isLocked 2015-02-23 18:39:41 +00:00
Michael Walker
14b08ff026 Un-break detection of global deadlock 2015-02-23 18:23:58 +00:00
Michael Walker
4a69fde83e Enable detection of nonglobal deadlock when every thread is in a fully-known state. Closes #9. 2015-02-23 17:58:12 +00:00
Michael Walker
f626e79553 Implement the new primitives in stepThread 2015-02-23 17:32:08 +00:00
Michael Walker
b8ff9a77f5 Add primitives for the new testing functions 2015-02-23 17:27:26 +00:00
Michael Walker
e72b84c613 Add an internal STM module 2015-02-23 17:24:02 +00:00
Michael Walker
2a6cbe8951 Add functions to MonadConc to record known vars 2015-02-23 17:23:26 +00:00
Michael Walker
0e3ba970bd Make CRefs interesting 2015-02-20 18:49:19 +00:00
Michael Walker
5862d536ca Use default writeCRef for IO 2015-02-20 16:53:38 +00:00
Michael Walker
0ea2930862 Implement CRefs in stepThread 2015-02-20 16:24:21 +00:00
Michael Walker
a4a291368d Add primitives for CRefs 2015-02-20 16:14:50 +00:00