Actions
shareshare link cite add Please grant OpenAIRE to access and update your ORCID works.This Research product is the result of merged Research products in OpenAIRE.
You have already added 0 works in your ORCID record related to the merged Research product.
See an issue? Give us feedback
Please grant OpenAIRE to access and update your ORCID works.
This Research product is the result of merged Research products in OpenAIRE.
You have already added 0 works in your ORCID record related to the merged Research product.
You have already added 0 works in your ORCID record related to the merged Research product.
Publication . Conference object . Article . 2019
Optimization of Swift Protocols
Rajkishore Barik; Manu Sridharan; Murali Krishna Ramanathan; Milind Chabbi;
Rajkishore Barik; Manu Sridharan; Murali Krishna Ramanathan; Milind Chabbi;
Open Access English
Published: 12 Aug 2019
Publisher: Zenodo
Abstract
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.
Subjects by Vocabulary
Microsoft Academic Graph classification: Dynamic dispatch Swift computer.programming_language computer Reference type Dataflow Protocol (object-oriented programming) Parallel computing Mock object Compiler computer.software_genre Computer science Speedup
Subjects
Safety, Risk, Reliability and Quality, Software
Safety, Risk, Reliability and Quality, Software
Microsoft Academic Graph classification: Dynamic dispatch Swift computer.programming_language computer Reference type Dataflow Protocol (object-oriented programming) Parallel computing Mock object Compiler computer.software_genre Computer science Speedup
Related Organizations
- University of California, Riverside United States
See an issue? Give us feedback
Beta
Fields of ScienceView all & feedback
Download fromView all 6 sources
Do the share buttons not appear? Please make sure, any blocking addon is disabled, and then reload the page.