Ghent University. Faculty of Sciences
Taming nondeterminism : programming language abstractions and tools for dealing with nondeterministic programs
Abstract
dc:descriptionComputer programs need to deal with nondeterministic environments. This nondeterminism may arise from many sources, like user input and concurrency for example. If program input were to be deterministic, there would be no need for complex programs. A word processor with deterministic input can simply present the user with their envisioned written document without them having to type it. Nondeterminism caused by concurrency stems from the unknown speed of each thread, the possibility of lost messages and so on. Although it leads to nondeterministic execution, we sometimes need it to fulfill real-world demands such as execution performance and high availability. If a program is nondeterministic, the next state may be one of multiple possibilities. When writing the program, the developer must imagine all possible executions to prevent bugs. Even if there are only two possibilities per program step, there are 2^n possible executions of n steps. This exponential state explosion is what makes working with nondeterminism so difficult. If a failure occurs in one of the myriad of execution traces, it is difficult to find its root cause. Typical debuggers only allow users the debug just one of the possible traces, while the failure may only manifest in very rare execution traces. Both humans and computers cannot deal with state explosion well. Programming languages have nondeterminism introducing constructs to facilitate working in nondeterministic environments. There are constructs for acquiring input, starting concurrent threads and so on. The chosen constructs greatly impact the nondeterminism the programmer has to deal with. In this dissertation we investigate the tree main ways programming systems can work with nondeterminism: embrace it, capture it, and avoid it. First, to embrace nondeterminism we must have the tools to deal with the state explosion it generates. In this dissertation, we present a tool called GraphRedex, which allows exploring the state space graph of nondeterministic programs. Our tool contributes a novel exploration technique for dealing with state explosion: interactive exploration. We allow developers to choose what path in the state space graph they want to follow. This helps developers see the wood for the trees when visualizing all possible execution paths of a program. We conducted a user study to confirm GraphRedex is user friendly and helps uncover bugs. Additionally, we used it to find errors in published research. A second option is to capture the nondeterminism. When something goes wrong in a program’s execution, it is often difficult to determine the exact conditions that triggered a bug. By keeping track of the nondeterministic choices the program makes during its execution, we can replay them, even backwards. If the program failed, stepping backwards can help find the bug that caused the failure. We have implemented such a backwards stepping functionality for a platform that is notoriously difficult to debug or even write programs for: microcontrollers. To do this, we created a WebAssembly virtual machine (VM) for these devices. Our VM, WARDuino allows programmers to use higher level languages to program microcontrollers. A language interoperability layer ensures that device peripherals are safely accessible. While higher level languages alone already prevent bugs, WARDuino additionally allows debugging applications remotely via a VSCode plugin. We show that our novel event-based out-of-place debugging technique reduces debugging latency and permits backwards stepping. Additionally, we determine that WARDuino is fast enough to implement IoT applications by carrying out micro benchmarks. Third, nondeterminism can be avoided by carefully selecting the provided language constructs. As an example of this approach, this dissertation presents Gaiwan. This is a general-purpose GPU (GPGPU) programming language intended for processing time series data. The language is based on a novel size-polymorphic type system we designed and implemented Additionally, Gaiwan only features race condition free constructs. By using our language, non-expert GPGPU users avoid two sources of nondeterminism: the nondeterministic size of the input, and the nondeterminism arising from data races on these extremely parallel devices. Gaiwan’s type system allows developers to use affine functions in one variable to declare the effect parts of their program have on data buffers. From this, our type system derives a set of constraints to which the input should adhere for the program to work. Inputs that do not satisfy these constraints will be rejected. Gaiwan prevents data races by only providing deterministic data race free language constructs. We provide the standard correctness proofs for our type system. Although our proof-of-concept evaluator is not yet fully optimized, we also implement a bitonic sorting algorithm in it and demonstrate that it only has a 25% overhead compared to a handwritten OpenCL implementation from Intel.
Degree
thesis:*- Grantor dc:publisher
- Ghent University. Faculty of Sciences
- Year dc:date
- 2022
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Gurdeep Singh, Robbert
- Contributors dc:contributor
-
- Scholliers, Christophe
- Mesuere, Bart
Subjects
dc:subject × 2Rights
dc:rights- Statement dc:rights
-
- info:eu-repo/semantics/openAccess
- Language dc:language
- eng