There is a newer version of this record available.

Conference paper Open Access

Optimization of Swift Protocols

Barik, Rajkishore; Sridharan, Manu; Ramanathan, Murali Krishna; Chabbi, Murali


Dublin Core Export

<?xml version='1.0' encoding='utf-8'?>
<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
  <dc:creator>Barik, Rajkishore</dc:creator>
  <dc:creator>Sridharan, Manu</dc:creator>
  <dc:creator>Ramanathan, Murali Krishna</dc:creator>
  <dc:creator>Chabbi, Murali</dc:creator>
  <dc:date>2019-08-12</dc:date>
  <dc:description>Title: Optimization of Swift Protocols

Abstract:

Swift, an increasingly-popular programming language, advocates the use of protocols, which define a set of required methods and properties for conforming types.  Protocols are commonly used in Swift programs for abstracting away implementation details; e.g., in an industrial app, they are heavily used to enable mock objects for unit testing.  Unfortunately, heavy use of protocols can result in significant performance overhead.  Beyond the dynamic dispatch often associated with such a feature, Swift allows for both value and reference types to conform to a protocol, leading to significant boxing and unboxing overheads.

In this paper, we describe three new optimizations and transformations we have developed to reduce the overhead of Swift protocols.  Within a procedure, we define LocalVar, a data-flow analysis and transformation to remove both dynamic dispatch and boxing overheads.  We also describe Param, which optimizes the case of protocol-typed method parameters using specialization.  Finally, we describe SoleType, a transformation that injects casts when a global analysis (like type-hierarchy analysis) discovers some protocol variable must have some concrete type.  We also describe how these optimizations work fruitfully together and with existing Swift optimizations to deliver further speedups.

We perform elaborate experimentation and demonstrate that our optimizations deliver an average 1.56x speedup on a suite of Swift benchmarks that use protocols. Further, we applied the optimizations to a production iOS Swift application used by millions of customers daily. For a set of performance spans defined by the developers of the application, the optimized version showed speedups ranging from 6.9% to 55.49%. A version of our optimizations has been accepted as part of the official Swift compiler distribution.</dc:description>
  <dc:identifier>https://zenodo.org/record/3366380</dc:identifier>
  <dc:identifier>10.5281/zenodo.3366380</dc:identifier>
  <dc:identifier>oai:zenodo.org:3366380</dc:identifier>
  <dc:language>eng</dc:language>
  <dc:relation>doi:10.5281/zenodo.3366379</dc:relation>
  <dc:rights>info:eu-repo/semantics/openAccess</dc:rights>
  <dc:rights>https://creativecommons.org/licenses/by/4.0/legalcode</dc:rights>
  <dc:title>Optimization of Swift Protocols</dc:title>
  <dc:type>info:eu-repo/semantics/conferencePaper</dc:type>
  <dc:type>publication-conferencepaper</dc:type>
</oai_dc:dc>
185
128
views
downloads
All versions This version
Views 18599
Downloads 12857
Data volume 15.8 GB8.4 GB
Unique views 16891
Unique downloads 3218

Share

Cite as