Commit Graph

6 Commits

Author SHA1 Message Date
William Dillon
7be98b0e73 Reduce memory threshold for expression_too_complex
The 5000 byte treshold is too generous on 32-bit systems to trigger the expression too complex test.  Reducing it to 4000 causes the compiler to bail (as expected) on these platforms while retaining the expected behavior on 64-bit systems.
2016-02-10 21:38:22 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Doug Gregor
45953c5b96 Solver: try binding collection literals before non-collection literals.
Trying a collection literal early often means that we can determine
the element type from context, which saves us the work of trying to
guess at the element type firsthand.

Doing this seems to help some cases significantly: 
  - test/stdlib/ArrayNew.swift got about 20% faster in a release build
  - I had to drop the threshold for the "expression too complex" test
    case by 20x to still trigger the issue.






Swift SVN r22097
2014-09-18 20:40:20 +00:00
Joe Pamer
a7a541fb1a Turn the "expression too complex" note into a proper error, and stop printing any auxiliary diagnostics that are produced as a result of the incompletely solved system. The "too complex" note had discoverability issues in Xcode, and the auxiliary errors were often misleading. (rdar://problem/18151024)
Swift SVN r21790
2014-09-08 22:43:29 +00:00
Argyrios Kyrtzidis
628567bfe5 [Frontend] Make it erroneous if no frontend action is specified when invoking the frontend, and update tests.
Swift SVN r21584
2014-08-29 19:17:37 +00:00
Joe Pamer
71cf758055 Mitigate exponential solver behavior (rdar://problem/17162690)
While we work out the remaining performance improvements in the type checker, we can improve the user experience for some "runaway solver" bugs by setting a limit on the amount of temporary memory allocated for type variables when solving over a single expression.

Exponential behavior usually manifests itself while recursively attempting bindings over opened type variables in an expression. Each one of these bindings may result in one or more fresh type variables being created. On average, memory consumption by type variables is fairly light, but in some exponential cases it can quickly grow to many hundreds of megabytes or even gigabytes. (This memory is managed by a distinct arena in the AST context, so it's easy to track.) This problem is the source of many of the "freezing" compiler and SourceKit bugs we've been seeing.

These changes set a limit on the amount of memory that can be allocated for type variables while solving for a single expression. If the memory threshold is exceeded, we can surface a type error and suggest that the user decompose the expression into distinct, less-complex sub-expressions.

I've set the current threshold to 15MB which, experimentally, avoids false positives but doesn't let things carry on so long that the user feels compelled to kill the process before they can see an error message. (As a point of comparison, the largest allocation of type variable data while solving for a single expression in the standard library is 592,472 bytes.) I've also added a new hidden front-end flag, "solver-memory-threshold", that will allow users to set their own limit, in bytes.

Swift SVN r20986
2014-08-03 23:10:42 +00:00