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


Citation Style Language JSON Export

{
  "publisher": "Zenodo", 
  "DOI": "10.5281/zenodo.3366380", 
  "language": "eng", 
  "title": "Optimization of Swift Protocols", 
  "issued": {
    "date-parts": [
      [
        2019, 
        8, 
        12
      ]
    ]
  }, 
  "abstract": "<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>", 
  "author": [
    {
      "family": "Barik, Rajkishore"
    }, 
    {
      "family": "Sridharan, Manu"
    }, 
    {
      "family": "Ramanathan, Murali Krishna"
    }, 
    {
      "family": "Chabbi, Murali"
    }
  ], 
  "type": "paper-conference", 
  "id": "3366380"
}
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