Compile-Time Safety and Runtime Performance in Programming Frameworks for Distributed Systems
Total Page:16
File Type:pdf, Size:1020Kb
Compile-time Safety and Runtime Performance in Programming Frameworks for Distributed Systems lars kroll Doctoral Thesis in Information and Communication Technology School of Electrical Engineering and Computer Science KTH Royal Institute of Technology Stockholm, Sweden 2020 School of Electrical Engineering and Computer Science KTH Royal Institute of Technology TRITA-EECS-AVL-2020:13 SE-164 40 Kista ISBN: 978-91-7873-445-0 SWEDEN Akademisk avhandling som med tillstånd av Kungliga Tekniska Högskolan fram- lägges till offentlig granskning för avläggande av teknologie doktorsexamen i informations- och kommunikationsteknik på fredagen den 6 mars 2020 kl. 13:00 i Sal C, Electrum, Kungliga Tekniska Högskolan, Kistagången 16, Kista. © Lars Kroll, February 2020 Printed by Universitetsservice US-AB IV Abstract Distributed Systems, that is systems that must tolerate partial failures while exploiting parallelism, are a fundamental part of the software landscape today. Yet, their development and design still pose many challenges to developers when it comes to reliability and performance, and these challenges often have a negative impact on developer productivity. Distributed programming frameworks and languages attempt to provide solutions to common challenges, so that application developers can focus on business logic. However, the choice of programming model as provided by a such a framework or language will have significant impact both on the runtime performance of applications, as well as their reliability. In this thesis, we argue for programming models that are statically typed, both for reliability and performance reasons, and that provide powerful abstractions, giving developers the tools to implement fast algorithms without being constrained by the choice of the programming model. Furthermore, we show how the design of Domain Specific Languages (DSLs) for such distributed programming frameworks, as well as DSLs for testing these components written in them, can reduce the mental gap between theoretical algorithms and their implementation, in turn reducing the risk of introducing subtle bugs. Concretely, we designed and implemented two different versions of the Kompics Component Model. The first is called Kompics Scala and focuses on pattern matching of events, as well as programming ergonomics and similarity to theoretical algorithms. The second version is called Kola and is a language with a compiler of its own, focusing on compile-time safety. Finally, we present a third framework, called Kompact, implementing a hybrid Actor–Component model which is designed around runtime-performance and static typing, and is implemented in the Rust language. In order to compare our solutions to the state-of-the-art, we present the first cross-language, distributed, message-passing benchmarking suite. We evaluated the impact of network abstractions in these models on performance, and show that our approach offers between 2 and 5 improvements on throughput £ £ for certain applications. We also evaluated the performance tradeoffs of different message-passing models and different implementations of the same model. We show that all our implementations are competitive, and our hybrid model, in particular, has significant benefits in a wide range of scenarios, leading to improvements of up to 27 compared to the state-of-the-art of message-passing systems. £ V Sammanfattning Distribuerade system, det vill säga system som tolererar partiella fel medan paral- lelism utnyttjas, är en grundläggande del av landskapet för mjukvaruutveckling idag. Ändå utgör dessas utveckling och design fortfarande många utmaningar för utvecklare när det gäller tillförlitlighet och prestanda, och dessa utmaningar har ofta en negativ inverkan på utvecklarens produktivitet. Distribuerade programme- ringsramverk och -språk försöker att ge lösningar på vanliga utmaningar, så att applikationsutvecklare kan fokusera på applikationslogik. Sådant ramverk eller språk är baserad på en programmeringsmodell, vars val har en betydande inverkan både på applikationernas runtime-prestanda, liksom dessas tillförlitlighet. I den här avhandlingen argumenterar vi för programmeringsmodeller som är statiskt typade, både av tillförlitlighets- och prestandaskäl, och som ger kraftfulla abstraktioner, vilket ger utvecklarna verktyg för att implementera snabba algo- ritmer utan att begränsas av valet av programmeringsmodell. Dessutom visar vi hur utformningen av domänspecifika språk (DSL) för sådana distribuerade programmeringsramverk, liksom DSL:er för att testa dessa komponenter skrivna i dem, kan minska den mentala klyftan mellan teoretiska algoritmer och dessas implementation, vilket i följd minskar risken för introduktion av subtila buggar. Specifikt, har vi utformat och implementerat två olika versioner av Kompics Compo- nent modellen. Den första heter Kompics Scala och fokuserar på mönstermatchning av event, samt programmeringsergonomi och likhet med teoretiska algoritmer. Den andra versionen heter Kola som är ett språk och sin egen kompilator med fokus på sä- kerhet i kompileringstid. Slutligen presenterar vi ett tredje ramverk, kallad Kompact, som implementerar en hybrid Actor-Component modell. Ramverket är utformad kring runtime-prestanda och statisk typning, och är implementerad i språket Rust. För att jämföra våra lösningar med andra state-of-the-art lösningar, presenterar vi den första flerspråkiga, distribuerade, message-passing benchmarking-sviten. Vi utvärderade effekterna av nätverksabstraktioner i dessa modeller på prestanda och visar att vår strategi erbjuder mellan 2 till 5 förbättringar av kapaciteten för vissa £ £ applikationer. Vi utvärderade också prestanda-tradeoffs för olika message-passing modeller och olika implementationer av samma modell. Vi visar att alla våra imple- mentationer är konkurrenskraftiga, och särskilt att vår hybridmodell har betydande fördelar i ett brett spektrum av scenarion, vilket leder till förbättringar på upp till 27 jämfört med den mest kända state-of-the-art message-passing system. £ VI Acknowledgements Like the proverbial Rome, a doctoral dissertation is not built (or written) in a day, and certainly not by a single person alone. Over the years in which the work, that finally resulted in this dissertation, took place, many people have shared ideas with me, let me bounce my own ideas off of them, pointed out challenges, fixed issues, showed me possible directions for progress or inquiry, and supported me in a myriad of other ways. First and foremost among the guides and supporters is my main advisor, Seif Haridi, who time and again has listened to all the wild ideas running around in my head and then subsequently helped me shape them into something that can actually be called “research”. Without him, I would likely still be writing lines upon lines of code in my office and this dissertation would simply be a dream for a far off future “when I am done”. In those situations when it did happen that I got badly stuck, with no clue where to go from there, it was usually the bursting fountain of ideas that is my secondary supervisor, Jim Dowling, who sparked the idea that led to the next step or goal. And, of course, it was also Jim who gave me the opportunity and convinced me to start a PhD in the first place. Thus, this dissertation would also have been equally impossible without him. For this, as well as every inspiring conversation, every boat trip, and every lunch, dinner, and beer we have shared over the past years, I am profoundly grateful. Over an even greater number of lunches, dinners, beers, coffees, whiskies, and pipes my friends, colleagues, and occasional house and office mates — Paris Carbone and Alex Ormenis, an — have acted as sounding boards for silly ideas, sources of inspiration and wild dreams, as testers, fixers, and collaborators, or simply as much needed stress relief and emotional support. Above everyone else, they helped me to get through the last few years and maintain some semblance of sanity and for that I cannot be thankful enough. Much the same holds true, of course, for my more remote friends, who have turned all my vacations from “working from a different location” to a joyful and re-energising experience and many of which share my favourite hobby of playing TTRPGs with me every single week: Chrischi, Ercan, Ivy, Jakob, Jenny, Malte, Olga, Rain, Sergio, and Teri. Of course, I could not have made it through all these years of education — or life, for that matter — without the support of my parents, grandparents, and my sister. They were always there, whether I needed advice or help, a place to stay for a few weeks, extra funds, or simply a lovely meal and a pleasant conversation. I may have spent a few more years in education than either of us bargained for, but I am immensely grateful to my family for not just putting up with it, but even encouraging me to go further. I would also like to thank all the master’s students who worked on bringing our shared ideas to life over the years: Ifeanyi Ubah has been integral in the development of the Kompics Testing framework and I have greatly enjoyed our extremely fruitful brainstorming sessions. Johan Mickos has been responsible for Kompact’s original networking implementation and his work is being continued ACKNOWLEDGEMENTS VII now by Adam Hasselberg. Both of them are smart and driven individuals, who, I can only say, are and have been a pleasure to work with. Harald Ng has put countless hours of work into the benchmarking suite, and without his invaluable help the suite would not be as large as it