Note that two optimizations described in the paper, Param and SoleType, are already integrated as part of the open source Swift compiler: SoleType (https://github.com/apple/swift/blob/master/lib/SILOptimizer/Analysis/ProtocolConformanceAnalysis.cpp) and Param (https://github.com/apple/swift/blob/master/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp). Both the optimizations are enabled by default. However, the third optimization LocalVar is not yet been pushed to Swift open source repository.

We have two sets of experiments in the paper, one on open-source benchmarks (Sections 6.1 and Sections 6.2) and another on proprietary UBER code (Section 6.3). Unfortunately, we will not be able to share the UBER code. We have created a SampleApp (described below) that mimicks some of the functionalites of our app. Tables 4 and 5 of the paper, on open-source benchmarks, can be reproduced using the Benchmark section below.

Build Instructions (From Source)

We have three different implementations:

1) swift-4.2-app-evaluation.tar.gz => This version of the Swift compiler (v4.2) was used to produce the results in Figure 5 (proprietary application).

2) swift-master-oopsla-submission.tar.gz => This version of the Swift compiler (v5.0) with specific versions of the base code as (1) swift git sha 82c33dc0311a8874c333c8478d9c7251a21417ec, (2) LLVM 6ddb64316c, (3) Clang 8bf0fa1829, and (4) Swift b5aabd1747. This version works with Mac OS 10.14, which is when we made the OOPSLA submission.

3) swift-master-08052019.tar.gz => This version of the Swift compiler (v5.1) was downloaded on August 5th 2019. This version works with Mac OS v10.15, which we had to develop for the SampleApp. as requested by reviewers (https://github.com/rajbarik/OOPSLA-2019-SampleApp).

All the above three implementations contain our three optimizations SoleType, Param, and LocalVar under swiftc compiler flags "-Xfrontend -sil-sole-type-propagation", "-Xfrontend -sil-existential-specializer", and "-Xfrontend -sil-existential-value-specializer" respectively. Newer version of Mac OS (10.14.6+) may choose to use implementation 3) above. The name of the git branch for our optimizations is "raj-dead-existential". It is easy to determine the code changes from master using "git diff master". Please use the instructions at https://github.com/apple/swift/ to build the above implementations -- please make sure compatible versions of LLVM, Clang, LLDB, etc are downloaded before building any of them.

Binary distribution

Since Apple's toolchain is changing rapidly and build from source is very fragile, we provide binary version of the compiler with all our changes. We provide two binary distributions: one for reproducing the results of the paper in Tables 4 and 5 (filename "binary.tar.gz"); another using a most recent version of the swift compiler to specifically build the SampleApp below (filename "swift-master-oopsla-submission.tar.gz". Both versions have been tested to run on Mac OS 10.14.6+.

Benchmarks

Benchmarks are available in benchmarks.tar.gz.

Reproduction of Table 4 and Table 5

  1. Unzip "benchmarks.tar.gz"
  2. Unzip "binary.tar.gz" or
  3. Build the compiler from the implementation "swift-master-oopsla-submission.tar.gz" using the "Build Instructions" above.

  4. Build the compiler from the implementation "swift-master-oopsla-submission.tar.gz" using the "Build Instructions" above.

  5. Point SWIFTC in benchmarks/perf.sh and benchmarks/size.sh to the one from the "bin" directory (obtained from unzipping binary.tar.gz) For example, "export SWIFTC="pwd/../bin/swiftc""

  6. Point SDKROOT in benchmarks/perf.sh and benchmarks/size.sh to the appropriate SDKROOT in the system. SDKROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"

  7. Platform to reproduce Table 4 and 5: Macbook Pro/iMac Pro Mac OS 10.14 or higher

  8. For reproducing Table 4 performance numbers, please run "benchmarks/perf.sh" from benchmarks directory and find the results in benchmarks/table-4-perf.txt.

  9. For reproducing Table 5 code size numbers, please run "benchmarks/size.sh" from benchmarks directory and find the results in benchmarks/table-5-size.txt.

SampleApp

This is a smaller version of the proprietary benchmark used in Section 6.3 of the paper (filename "sampleapp.tar.gz"). It uses Swift Package manager.

  1. Unzip sampleapp.tar.gz

  2. Unzip "binary-swift-master-oopsla-submission.tar.gz"

or

  1. Build the compiler from the implementation "swift-master-oopsla-submission.tar.gz" using the "Build Instructions" above.

  2. Update run-scr in sampleapp to update SWIFT_EXEC to point to one from 2.

  3. Copy Package.swift_unopt to Package.swift [For unoptimized build] and execute "run-scr"

  4. Copy Package.swift_opt to Package.swift [For optimized build] and execute "run-scr"

The Unoptimized and Optimized versions should show a speedup of 12% or more on a 6-core MacBook Pro 2018.

Questions/Comments:

Raj Barikrkbarik@gmail.com