{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2025,6,18]],"date-time":"2025-06-18T04:27:24Z","timestamp":1750220844857,"version":"3.41.0"},"reference-count":40,"publisher":"Association for Computing Machinery (ACM)","issue":"OOPSLA","license":[{"start":{"date-parts":[[2019,10,10]],"date-time":"2019-10-10T00:00:00Z","timestamp":1570665600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. ACM Program. Lang."],"published-print":{"date-parts":[[2019,10,10]]},"abstract":"<jats:p>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 a large industrial app from Uber, 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.<\/jats:p>\n          <jats:p>In this paper, we describe three new optimizations and transformations to reduce the overhead of Swift protocols. Within a procedure, we define LocalVar, a dataflow 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.<\/jats:p>\n          <jats:p>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 from Uber 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.<\/jats:p>","DOI":"10.1145\/3360590","type":"journal-article","created":{"date-parts":[[2019,10,11]],"date-time":"2019-10-11T14:53:33Z","timestamp":1570805613000},"page":"1-27","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":2,"title":["Optimization of swift protocols"],"prefix":"10.1145","volume":"3","author":[{"given":"Rajkishore","family":"Barik","sequence":"first","affiliation":[{"name":"Uber Technologies, USA"}],"role":[{"role":"author","vocabulary":"crossref"}]},{"given":"Manu","family":"Sridharan","sequence":"additional","affiliation":[{"name":"University of California at Riverside, USA"}],"role":[{"role":"author","vocabulary":"crossref"}]},{"given":"Murali Krishna","family":"Ramanathan","sequence":"additional","affiliation":[{"name":"Uber Technologies, USA"}],"role":[{"role":"author","vocabulary":"crossref"}]},{"given":"Milind","family":"Chabbi","sequence":"additional","affiliation":[{"name":"Uber Technologies, USA"}],"role":[{"role":"author","vocabulary":"crossref"}]}],"member":"320","published-online":{"date-parts":[[2019,10,10]]},"reference":[{"key":"e_1_2_1_1_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-47910-4_14"},{"key":"e_1_2_1_2_1","doi-asserted-by":"publisher","DOI":"10.1145\/2594291.2594332"},{"key":"e_1_2_1_3_1","doi-asserted-by":"publisher","DOI":"10.1109\/HPCA.2011.5749748"},{"key":"e_1_2_1_4_1","unstructured":"AppleOTA 2019. Apple Over-The-Air Requirements. https:\/\/developer.apple.com\/accessories\/Accessory- Design- Guidelines. pdf . Accessed: 2019-04-01.  AppleOTA 2019. Apple Over-The-Air Requirements. https:\/\/developer.apple.com\/accessories\/Accessory- Design- Guidelines. pdf . Accessed: 2019-04-01."},{"key":"e_1_2_1_5_1","doi-asserted-by":"publisher","DOI":"10.1145\/236337.236371"},{"key":"e_1_2_1_6_1","unstructured":"BucketSort 2019. BucketSort. https:\/\/github.com\/raywenderlich\/swift- algorithm- club\/tree\/master\/Bucket%20Sort . Accessed: 2019-01-29.  BucketSort 2019. BucketSort. https:\/\/github.com\/raywenderlich\/swift- algorithm- club\/tree\/master\/Bucket%20Sort . Accessed: 2019-01-29."},{"key":"e_1_2_1_7_1","doi-asserted-by":"publisher","DOI":"10.1145\/349299.349306"},{"key":"e_1_2_1_8_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-49538-X_5"},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-48743-3_12"},{"key":"e_1_2_1_10_1","doi-asserted-by":"publisher","DOI":"10.1145\/800017.800542"},{"key":"e_1_2_1_11_1","doi-asserted-by":"publisher","DOI":"10.1109\/CGO.2017.7863745"},{"key":"e_1_2_1_12_1","doi-asserted-by":"publisher","DOI":"10.1145\/207110.207121"},{"key":"e_1_2_1_13_1","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0055522"},{"key":"e_1_2_1_14_1","doi-asserted-by":"publisher","DOI":"10.1145\/1542476.1542528"},{"key":"e_1_2_1_15_1","volume-title":"Design Patterns: Elements of Reusable Object-oriented Software","author":"Gamma Erich","year":"1995","unstructured":"Erich Gamma , Richard Helm , Ralph Johnson , and John Vlissides . 1995 . Design Patterns: Elements of Reusable Object-oriented Software . Addison-Wesley Longman Publishing Co., Inc. , Boston, MA, USA . Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. 1995. Design Patterns: Elements of Reusable Object-oriented Software. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA."},{"key":"e_1_2_1_16_1","doi-asserted-by":"publisher","DOI":"10.1145\/1216374.1216379"},{"key":"e_1_2_1_17_1","volume-title":"Swift 4 Protocol-Oriented Programming","author":"Hoffman Jon","unstructured":"Jon Hoffman . 2019. Swift 4 Protocol-Oriented Programming ( 3 rd ed.). Packt Publishing . Jon Hoffman. 2019. Swift 4 Protocol-Oriented Programming (3rd ed.). Packt Publishing.","edition":"3"},{"key":"e_1_2_1_18_1","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0057013"},{"key":"e_1_2_1_19_1","doi-asserted-by":"publisher","DOI":"10.1145\/178243.178478"},{"key":"e_1_2_1_20_1","doi-asserted-by":"publisher","DOI":"10.1145\/130697.130698"},{"key":"e_1_2_1_21_1","doi-asserted-by":"publisher","DOI":"10.1145\/353171.353191"},{"key":"e_1_2_1_22_1","doi-asserted-by":"publisher","DOI":"10.1145\/199448.199536"},{"key":"e_1_2_1_23_1","doi-asserted-by":"publisher","DOI":"10.1145\/2508168.2508177"},{"key":"e_1_2_1_24_1","unstructured":"Steve Klabnik and Carol Nichols. 2019. The Rust Programming Language. https:\/\/doc.rust- lang.org\/stable\/book\/ . Accessed: 2019-04-05.  Steve Klabnik and Carol Nichols. 2019. The Rust Programming Language. https:\/\/doc.rust- lang.org\/stable\/book\/ . Accessed: 2019-04-05."},{"key":"e_1_2_1_25_1","doi-asserted-by":"publisher","DOI":"10.1145\/99583.99599"},{"key":"e_1_2_1_26_1","doi-asserted-by":"publisher","DOI":"10.1007\/BF03037261"},{"key":"e_1_2_1_27_1","volume-title":"Types and Programming Languages","author":"Pierce Benjamin C.","unstructured":"Benjamin C. Pierce . 2002. Types and Programming Languages ( 1 st ed.). The MIT Press . Benjamin C. Pierce. 2002. Types and Programming Languages (1st ed.). The MIT Press.","edition":"1"},{"key":"e_1_2_1_28_1","doi-asserted-by":"publisher","DOI":"10.1145\/2594291.2594316"},{"key":"e_1_2_1_29_1","doi-asserted-by":"publisher","DOI":"10.1145\/778559.778561"},{"key":"e_1_2_1_30_1","doi-asserted-by":"publisher","DOI":"10.1145\/53990.54007"},{"key":"e_1_2_1_32_1","unstructured":"SILDocs 2019. Swift Intermediate Language (SIL). https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/SIL.rst . Accessed: 2019-03-22.  SILDocs 2019. Swift Intermediate Language (SIL). https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/SIL.rst . Accessed: 2019-03-22."},{"key":"e_1_2_1_33_1","unstructured":"SILSSA 2017. SIL SSA Updater. https:\/\/github.com\/apple\/swift\/blob\/master\/lib\/SILOptimizer\/Utils\/SILSSAUpdater.cpp . Accessed: 2019-01-29.  SILSSA 2017. SIL SSA Updater. https:\/\/github.com\/apple\/swift\/blob\/master\/lib\/SILOptimizer\/Utils\/SILSSAUpdater.cpp . Accessed: 2019-01-29."},{"key":"e_1_2_1_34_1","unstructured":"SILVerifier 2017. SILVerifier. https:\/\/github.com\/apple\/swift\/blob\/master\/lib\/SIL\/SILVerifier.cpp . Accessed: 2019-01-29.  SILVerifier 2017. SILVerifier. https:\/\/github.com\/apple\/swift\/blob\/master\/lib\/SIL\/SILVerifier.cpp . Accessed: 2019-01-29."},{"key":"e_1_2_1_35_1","doi-asserted-by":"publisher","DOI":"10.1145\/237721.237727"},{"key":"e_1_2_1_36_1","doi-asserted-by":"publisher","DOI":"10.1145\/353171.353189"},{"key":"e_1_2_1_37_1","unstructured":"SwiftBench 2019. Swift Benchmark Suite. https:\/\/github.com\/apple\/swift\/tree\/master\/benchmark . Accessed: 2019-01-29.  SwiftBench 2019. Swift Benchmark Suite. https:\/\/github.com\/apple\/swift\/tree\/master\/benchmark . Accessed: 2019-01-29."},{"key":"e_1_2_1_38_1","unstructured":"SwiftLang 2019. Swift Programming Language. https:\/\/github.com\/apple\/swift\/ . Accessed: 2019-01-29.  SwiftLang 2019. Swift Programming Language. https:\/\/github.com\/apple\/swift\/ . Accessed: 2019-01-29."},{"key":"e_1_2_1_39_1","unstructured":"SwiftLangDoc 2019. Swift Language Documentation. https:\/\/developer.apple.com\/documentation\/swift Accessed: 2019-04-01.  SwiftLangDoc 2019. Swift Language Documentation. https:\/\/developer.apple.com\/documentation\/swift Accessed: 2019-04-01."},{"key":"e_1_2_1_40_1","unstructured":"UberRibs 2017. Ribs: Cross Platform Mobile Architecture. https:\/\/github.com\/uber\/RIBs\/ . Accessed: 2019-01-29.  UberRibs 2017. Ribs: Cross Platform Mobile Architecture. https:\/\/github.com\/uber\/RIBs\/ . Accessed: 2019-01-29."},{"volume-title":"Understanding Swift Performance - Apple WWDC 2016","year":"2016","key":"e_1_2_1_41_1","unstructured":"WWDCSwiftPerf 2016 . Understanding Swift Performance - Apple WWDC 2016 . https:\/\/developer.apple.com\/videos\/play\/ wwdc2016\/416\/ . Accessed : 2019-01-29. WWDCSwiftPerf 2016. Understanding Swift Performance - Apple WWDC 2016. https:\/\/developer.apple.com\/videos\/play\/ wwdc2016\/416\/ . Accessed: 2019-01-29."}],"container-title":["Proceedings of the ACM on Programming Languages"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3360590","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3360590","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,6,17]],"date-time":"2025-06-17T23:22:59Z","timestamp":1750202579000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3360590"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2019,10,10]]},"references-count":40,"journal-issue":{"issue":"OOPSLA","published-print":{"date-parts":[[2019,10,10]]}},"alternative-id":["10.1145\/3360590"],"URL":"https:\/\/doi.org\/10.1145\/3360590","relation":{},"ISSN":["2475-1421"],"issn-type":[{"type":"electronic","value":"2475-1421"}],"subject":[],"published":{"date-parts":[[2019,10,10]]},"assertion":[{"value":"2019-10-10","order":2,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}