Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift-At-Scale-v3.pdf

Tomasz Gebarowski
July 21, 2017
74

 Swift-At-Scale-v3.pdf

Tomasz Gebarowski

July 21, 2017
Tweet

Transcript

  1. some stats +10 developers 2 years of development +3200 Swift

    files 100’s of View Controllers, Cells We use code generation 3 migrations between Swift versions tgebarowski
  2. https://github.com/riamf/XcodeBuildTimeMeasurement Day time (s) formatted time no builds 10.10.2016 7297

    2h 1m 37s 24 11.10.2016 12221 3h 23m 41s 87 12.10.2016 7146 1h 59m 5s 79 13.10.2016 8885 2h 28m 5s 107 14.10.2016 4452 1h 14m 12s 33 tgebarowski
  3. Why -Onone is so slow? In a large project, single

    Swift file compilation takes ~1 second
  4. specialisation of generic functions for concrete types inlining dead function/method

    elimination source: swift.org whole-module optimization tgebarowski
  5. swift -frontend -primary-file file1.swift -filelist file swift -whole-module-optimization file1.swift file2.swift

    file3.swift how it works? swift -Onone file1.swift file2.swift file3.swift swift -frontend -whole-module-optimization -filelist file swift -frontend -primary-file file2.swift -filelist file swift -frontend -primary-file file3.swift -filelist file spawn spawn spawn spawn -whole-module-optimization -Onone tgebarowski
  6. beware of large targets! getconf ARG_MAX 262144 uses absolute path

    of every Swift file in project +1500 Swift files Assume long project dir path MacOS command line
 max length tgebarowski
  7. -Onone -Owholemodule Core i5 ~18 min
 ~40 min ~10 min


    ~11 min Core i7 13 min
 ~30 min 8 min
 ~8 min compilation times after introducing frameworks tgebarowski
  8. Migrations Swift 1.2 Swift 2.1 Swift 2.2 2 days ~3

    weeks author: Christophe Boisson Swift 3 7 days tgebarowski
  9. Swift 1.2 Swift 2.1 ~3 weeks Swift 2.2 Swift 3

    7 days 8h Migration Tool 2 days Manual Fixes 2 devs 5 days Bypassing 
 compiler bug 3h Migration Tool 4 days Manual Fixes 3 devs ~3800 errors ~1600 errors 5 days Regression testing 2 days Regression testing
  10. migration process Auto migration Code Freeze Migrating Core frameworks Migrating

    App itself Migrating Unit and UI tests Regression and fixing issues Auto migration Migrating Core frameworks Estimating number and types of bugs to fix migration evaluation migration process tgebarowski
  11. Swift 3 Migration Issues • dequeueReusableCellWithIdentifier -> dequeueReusableCell(withIdentifier:for:) • hidden

    -> isHidden • enabled -> isEnabled • popViewControllerAnimated -> popViewController(animated:) • registerNib(_:forCellReuseIdentifier:) -> register(_:forCellReuseIdentifier:) • wszystkie błędy związane z rename’ing enumów ‚X’ has been renamed to ‚Y’ 551 errors extraneous argument label 250 errors explicitly marked unavailable here 570 errors has no case „X”, did you mean „x” 523 errors NSDate & Date related 114 errors tgebarowski
  12. swift -frontend swiftc swift -frontend posix_spawn swift -frontend … crash

    The +1500 Swift files problem (Xcode 7.2) tgebarowski
  13. Reported problem to Apple (SR-280) Fixed in Xcode 7.3 Provided

    a workaround for 7.2 swiftc wrapper swiftc -num-threads 0 with fork instead of posix_spawn Xcode More info: https://github.com/tgebarowski/swiftc-wrapper The +1500 Swift files problem (Xcode 7.2) tgebarowski
  14. • Swift 4 • Xcode 9 • precompiled frameworks •

    static libraries • Buck What’s next? tgebarowski