IOS and MacOS Performance Tuning by Weiher Marcel;

IOS and MacOS Performance Tuning by Weiher Marcel;

Author:Weiher, Marcel;
Language: eng
Format: epub
Publisher: Pearson Education Limited (US titles)
Published: 2017-11-14T16:00:00+00:00


* * *

let a = [ "level1": [ [ 1 ], [ 2 ], ... , [ n ]]

* * *

This is not a bug per se, but it is indicative of the inherent complexity of type-inference algorithms. For example, Scala’s creator Martin Odersky explains that Scala’s notoriously slow compile times are largely due to type inference.

This is also not a new problem. I remember reading about early attempts to improve the performance of the Self dynamic prototype-based language using compile-time type inferencing. The running times were so bad, in the minutes for small expressions, that the Self team had to turn to a different approach. Instead of figuring out the types at compile time, they just logged the types at runtime, which in fact they were already doing in their polymorphic inline caches. Using that type information gathered at runtime they then optimized the code, a technique that led in a straight line to the advanced JITs of today such as Java’s HotSpot.

Fortunately, it is often possible to special-case specific egregiously bad cases, and this particular problem was “fixed” in Swift 3: compile times for that particular construct are now “only” quadratic with n, so you need to have n = 200 to reach half a minute of compile time.

A similar issue that has not been fixed as of this writing is shown in Example 9.14. This will terminate with a compiler error about expressions that are too complex to be solved after around 3 s.

Example 9.14 Expression too complex to be solved in reasonable time

Click here to view code image



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.