作者
Alex Diaz
发表日期
2022
机构
KTH Royal Institute of Technology
简介
The Swift programming language recently introduced the actor model alongside Swift concurrency as a first-class citizen. Previously, concurrent programming in Swift required importing modules, eg, Grand Central Dispatch. Grand Central Dispatch is a concurrency framework, often used for implementing shared memory concurrency in Swift. In contrast to Grand Central Dispatch, the Swift actor provides implicit mutual exclusion via message passing concurrency and the notion of actor isolation. This thesis evaluates the performance of the Swift actor and Swift concurrency in comparison to thread-safe objects with Grand Central Dispatch. The study assembled a benchmark suite to measure the performance over central bottlenecks (Chameneos), large counts of independent objects (Dining Philosophers), long-living concurrent objects (Dining Philosophers) and massively parallel messaging (Big). The results indicate the lack of a catch-all solution to concurrent programming in Swift. In comparison to Grand Central Dispatch, a system of actors tends to require more memory to finish execution. By upper bounding concurrency in actors, memory use is effectively limited at the cost of possibly longer execution times. In particular, the results were gathered on a macOS computer. With unique implementations of threads in different operating systems, further studies are needed to evaluate Swift concurrency and the Swift actor on other systems and hardware. In addition, further studies may evaluate the risk of congestion at large numbers of concurrent actors.