Closed DavePearce closed 7 years ago
Here's another good example:
WARNING: version numbering unavailable
Parsed 1 source file(s). ....................................................... [73ms+3mb]
Typed 1 source file(s). ................................................... [56755ms-132mb]
Verified 1 source file(s). ................................................ [12847ms-149mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) ......................................... [69678ms-279mb]
So, type checking takes four times as long as verification ... what the ???
Another interesting case:
bash-3.2$ wy compile --verify --wyaldir=. --verbose Complex_Valid_7.whiley
WARNING: version numbering unavailable
Parsed 1 source file(s). ....................................................... [37ms+1mb]
Typed 1 source file(s). ........................................................ [28ms+1mb]
Generated code for 1 source file(s). ........................................... [49ms+1mb]
[/Users/djp/projects/WhileyTheoremProver/./Complex_Valid_7.wyil] applied coercion check [1ms]
Whiley => Wyil: compiled 1 file(s) ............................................ [130ms-2mb]
Wyil => Wyal: compiled 1 file(s) ............................................... [52ms+2mb]
Parsed 1 source file(s). ............................................................ [0ms]
Typed 1 source file(s). .................................................... [6241ms-162mb]
Verified 1 source file(s). ................................................. [1389ms-164mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) .......................................... [7630ms-327mb]
And another:
[/Users/djp/projects/WhileyTheoremProver/./ConstrainedList_Valid_3.wyil] applied coercion check [1ms]
Whiley => Wyil: compiled 1 file(s) ............................................ [127ms-2mb]
Wyil => Wyal: compiled 1 file(s) ............................................... [48ms+1mb]
Parsed 1 source file(s). ............................................................ [0ms]
Typed 1 source file(s). ..................................................... [5457ms-45mb]
Verified 1 source file(s). .................................................. [1328ms+19mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) ........................................... [6785ms-26mb]
bash-3.2$ wy compile --verify --wyaldir=. --verbose ConstrainedList_Valid_20.whiley
WARNING: version numbering unavailable
Parsed 1 source file(s). ....................................................... [33ms+1mb]
Typed 1 source file(s). ........................................................ [26ms+1mb]
Generated code for 1 source file(s). ........................................... [47ms+1mb]
[/Users/djp/projects/WhileyTheoremProver/./ConstrainedList_Valid_20.wyil] applied coercion check [0ms]
Whiley => Wyil: compiled 1 file(s) ............................................ [121ms-2mb]
Wyil => Wyal: compiled 1 file(s) ............................................... [44ms+1mb]
Parsed 1 source file(s). ............................................................ [0ms]
Typed 1 source file(s). .................................................... [1913ms-244mb]
Verified 1 source file(s). .................................................. [428ms+136mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) .......................................... [2341ms-107mb]
[/Users/djp/projects/WhileyTheoremProver/./ConstrainedList_Valid_23.wyil] applied coercion check [0ms]
Whiley => Wyil: compiled 1 file(s) ............................................ [133ms-2mb]
Wyil => Wyal: compiled 1 file(s) ............................................... [58ms+2mb]
Parsed 1 source file(s). ............................................................ [0ms]
Typed 1 source file(s). .................................................... [17245ms-45mb]
Verified 1 source file(s). ................................................. [3582ms-260mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) ......................................... [20828ms-305mb]
checkIsSubtype()
has no effect on performance.isApplicable()
to return true
leads to a 10x reduction in performance.Confirmed this with both ConstraintList_Valid_23
and Complex_Valid_7
.
One possible reason that isApplicable()
is causing problems is potentially because NameResolution
is expensive. Each call to isApplicable()
is not super long-running. Normally say 2ms
but occasionally up to 19ms
.
More points:
NameResolver
Caching. Caching of resolve()
calls does reduce the number of times that resolution is actually performed, but is not reducing overall performance at all. My guess is that this is coming from WyalFile enclosing = loadModule(nid,name);
in resolveAll()
.resolveAll()
. Even with caching enabled this isn't having much effect. After caching there we only 8
individual calls made accounting for maybe 20ms
in total.Right, am not making lots of progress here. So, this is the best information so far:
Parsed 1 source file(s). ....................................................... [77ms+3mb]
************ STATS
HITS: 0
MISSES: 0
RESOLVE: 354ms
RESOLVEALL: 1248ms
******************
Typed 1 source file(s). ..................................................... [9147ms-55mb]
Verified 1 source file(s). .................................................. [5805ms+69mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) .......................................... [15034ms+18mb]
It doesn't look like either of those are the real problem here. That would rule out WyalFileResolver
. Some more stats related to CoerciveSubtypeOperator.isSubtype()
:
=========== STATS ==============
CALL COUNT: 4913
WORKLIST COUNT: 34453
WORKLIST SIZE: 36708
================================
This counts: the number of calls to isSubtype()
, the number of calls to isVoid(ArrayList,Worklist,BitSet)
and the cumulative size of the worklist on each of those calls.
The above stats do look a bit odd if we consider the type being queried in that file:
type Matrix is ((int[])[] rows) where ...
This doesn't involve any unions or other things which might cause complication. I suppose we might expect a depth of three for that type, leading to say 4913 * 3 = 14739
calls.
The following loop ...
for (int i = 0; i != truths.size(); ++i) {
Atom<?> ith = truths.get(i);
for (int j = i + 1; j != truths.size(); ++j) {
Atom<?> jth = truths.get(j);
if (isVoidAtom(ith, jth, assumptions)) {
time += (System.currentTimeMillis() - start);
return true;
}
}
}
... is only accounting for around 1385ms
in this example. Doesn't seem to be the main contributing factor. That is still a lot of time unaccounted for.
One interesting observation is that the BitSet
assumptions is very big because of the number of SyntacticElement
s in the given file. Caching the creation of this BitSet
gives the following timing:
Typed 1 source file(s). .................................................... [3716ms-384mb]
Verified 1 source file(s). ................................................. [2724ms-143mb]
Generated code for 1 source file(s). ................................................ [0ms]
Wyal => Wyail: compiled 1 file(s) .......................................... [6518ms-524mb]
For the allValidVerification
test suite, this reduces the time from around 45ms
to 37ms
. Or, 152ms
to 126ms
if we remove the ignores on those too long for travis
.
UPDATE: using HashSetAssumptions
leads to better overall performance. This requires only 56ms
if we remove the ignores on those too long for travis
.
Resolved and released in v0.6.0
Some test cases are taking a long time to verify because of the type checker. It's going extremely slowly at times for reasons unknown. Here are some stats from
BoolList_Valid_3
:The first column is the number of subtype operations, and the second is the overall time for that assert to be type checked. The generic stats are: