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


JSON-LD (schema.org) Export

{
  "inLanguage": {
    "alternateName": "eng", 
    "@type": "Language", 
    "name": "English"
  }, 
  "description": "<p>Title:&nbsp;Optimization of Swift Protocols</p>\n\n<p>Abstract:</p>\n\n<p>Swift, an increasingly-popular programming language, advocates the use of protocols, which define a set of required methods and properties for conforming types. &nbsp;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. &nbsp;Unfortunately, heavy use of protocols can result in significant performance overhead. &nbsp;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.</p>\n\n<p>In this paper, we describe three new optimizations and transformations we have developed to reduce the overhead of Swift protocols. &nbsp;Within a procedure, we define LocalVar, a data-flow analysis and transformation to remove both dynamic dispatch and boxing overheads. &nbsp;We also describe Param, which optimizes the case of protocol-typed method parameters using specialization. &nbsp;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. &nbsp;We also describe how these optimizations work fruitfully together and with existing Swift optimizations to deliver further speedups.</p>\n\n<p>We perform elaborate experimentation and demonstrate that our&nbsp;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.</p>", 
  "license": "https://creativecommons.org/licenses/by/4.0/legalcode", 
  "creator": [
    {
      "affiliation": "Uber Technologies Inc.", 
      "@type": "Person", 
      "name": "Barik, Rajkishore"
    }, 
    {
      "affiliation": "University of California, Riverside", 
      "@type": "Person", 
      "name": "Sridharan, Manu"
    }, 
    {
      "affiliation": "Uber Technologies Inc.", 
      "@type": "Person", 
      "name": "Ramanathan, Murali Krishna"
    }, 
    {
      "affiliation": "Uber Technologies Inc.", 
      "@type": "Person", 
      "name": "Chabbi, Murali"
    }
  ], 
  "headline": "Optimization of Swift Protocols", 
  "image": "https://zenodo.org/static/img/logos/zenodo-gradient-round.svg", 
  "datePublished": "2019-08-12", 
  "url": "https://zenodo.org/record/3366380", 
  "@context": "https://schema.org/", 
  "identifier": "https://doi.org/10.5281/zenodo.3366380", 
  "@id": "https://doi.org/10.5281/zenodo.3366380", 
  "@type": "ScholarlyArticle", 
  "name": "Optimization of Swift Protocols"
}
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