Monday, 5 November 2018

How does your compiler cope with a 64 MB source file ?

gannett$ ls -l F6From36Line.swift 
-rw-r--r--  1 gannett  admin  64277489  5 Nov 19:26 F6From36Line.swift

gannett$ head F6From36Line.swift 
let StartDataA = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] 
let StartDataAofA = [ ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] ]
let OneBigBlock = [ ["0", "1", "2", "3", "4", "5"],
 ["0", "1", "2", "3", "4", "6"],
 ["0", "1", "2", "3", "4", "7"],
 ["0", "1", "2", "3", "4", "8"],
 ["0", "1", "2", "3", "4", "9"],
 ["0", "1", "2", "3", "4", "a"],
 ["0", "1", "2", "3", "4", "b"],
 ["0", "1", "2", "3", "4", "c"],

gannett$ tail F6From36Line.swift 
 ["s", "u", "v", "x", "y", "z"],
 ["s", "u", "w", "x", "y", "z"],
 ["s", "v", "w", "x", "y", "z"],
 ["t", "u", "v", "w", "x", "y"],
 ["t", "u", "v", "w", "x", "z"],
 ["t", "u", "v", "w", "y", "z"],
 ["t", "u", "v", "x", "y", "z"],
 ["t", "u", "w", "x", "y", "z"],
 ["t", "v", "w", "x", "y", "z"],
 ["u", "v", "w", "x", "y", "z"]]

gannett$ time swift F6From36Line.swift 
F6From36Line.swift:3:19: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
let OneBigBlock = [ ["0", "1", "2", "3", "4", "5"],
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
real 6m51.594s
user 2m37.196s

sys 2m55.832s



The background is exploring Swift, the language, using some big data structures to test the map, reduce and filter functionality. Using a combination generator to create an array of arrays that pulls 6 elements from a set of 36 items ended up with a 64Mb  text representation of an array of arrays. Running that file in to the Swift compiler gave the message listed above.  

Such a well mannered compiler :-)


Generating 3 elements from a group of 5 .. later converted into 3 let statements.


$ swift combiGenericTest.swift 3 1 2 3 4 5
DataIn = [["1", "2", "3", "4", "5"]]
startData = ["1", "2", "3", "4", "5"] 
DataIO=[["1", "2", "3", "4", "5"]]

In one block the full set is:

[ ["1", "2", "3"], 
["1", "2", "4"], 
["1", "2", "5"], 
["1", "3", "4"], 
["1", "3", "5"], 
["1", "4", "5"], 
["2", "3", "4"], 
["2", "3", "5"], 
["2", "4", "5"], 
["3", "4", "5"] ]


No comments: