Towards implicit parallel programming for systems

Processor architectures have reached a physical boundary that prevents scaling performance with the number of transistors. Effectively, this means that the sequential programs of the past will not gain performance boosts from new processor designs any more as they used to. Since singlecore performance does not scale anymore, new processor architectures now host several cores. In order to speedup execution with these multiple cores, a program needs to run in parallel. Ideally, a compiler could parallelize a program automatically and optimize it for a given multi-core architecture. But most prevalent programming languages encourage the developer to use state in order to avoid recomputations and make programs fast. Keeping track of state references is impossible in general and prevents compilers from parallelizing code automatically. The programer must manually transform its algorithm into a parallel version by leveraging concurrency constructs, such as threads and locks. Writing correct, i.e., data race free and deadlock free, concurrent code is hard. As such, parallel programming models often discard the state aspect. In this thesis, we propose the stateful functional programming (SFP) model. A program in our model consists of two abstractions an alogrithm and functions. We say that an algorithm defines the composition of functions. A function may operate on its own private state where each call-site of the function has a state assigned to it at runtime. This state is required to be private such that the associated compiler can automatically parallelize algorithms without introducing data races. The programming model is inspired by the well-known dataflow execution model which serves as the state-of-the-art for parallelizing data management systems and signal processing applications on embedded system. As such, our SFP compiler translates algorithms into dataflow graphs to provide dataflow parallelism implicitly to programs in the domain of server-based back-end infrastructures and data processing systems. In support of that, this thesis establishes the idea of stateful functional programming in the context of a server. The dataflow representation of the program allows us to study different well-known server designs and select the appropriate option with respect to a target metric, i.e., throughput, latency or energy-efficiency. To further evolve our SFP model, we study it as a part of a big data execution engine. The results show that the associated compiler and runtime system can introduce parallelism into parts that are current execution bottlenecks. In the second part of the thesis, we argue that our compiler and dataflow-based runtime can also solve problems that are directly connected to a parallel execution. In the context of large back-end infrastructures with lots of I/O, we show that our compiler can optimize I/O without requiring any code changes. This is possible because SFP algorithms adhere to a functional programming paradigm and as such directly translate into expressions of the lambda calculus. Our compiler uses the lambda calculus as its high-level intermediate representation (IR) and lowers expressions into the dataflow representation. This allows us to define (most of) the I/O optimizations as transformations on lambda expression and prove that they preserve the semantics of the program. In the context of highly-available server programs that need to evolve without down times, we define an algorithm for non-blocking live updates. Our dataflow-based runtime representation makes the communication in the program explicit and identifies side-effects to state. This information is the foundation to streamline change requests into the data stream that not only update a single node but whole parts of the graph. The algorithm thereby makes sure that the system transitions from one consistent state into another without requiring additional synchronization. To present interesting directions for future research, we analyze the applicability of our SFP model to the domain of data management systems, including database engines, data streaming engines and database applications.