Out-Of-Place Debugging: a Debugging Architecture to Reduce Debugging Interference
Total Page:16
File Type:pdf, Size:1020Kb
Out-Of-Place debugging: a debugging architecture to reduce debugging interference Matteo Marraa, Guillermo Politob, and Elisa Gonzalez Boixa a Vrije Universiteit Brussel, Brussels, Belgium b Univ. Lille, CNRS, Centrale Lille, Inria, UMR 9189 - CRIStAL - Centre de Recherche en Informatique Signal et Automatique de Lille, F-59000 Lille, France Abstract Context Recent studies show that developers spend most of their programming time testing, ver- ifying and debugging software. As applications become more and more complex, developers demand more advanced debugging support to ease the software development process. Inquiry Since the 70’s many debugging solutions have been introduced. Amongst them, online debuggers provide good insight on the conditions that led to a bug, allowing inspection and interaction with the variables of the program. However, most of the online debugging solutions introduce debugging interference to the execution of the program, i.e. pauses, latency, and evaluation of code containing side-effects. Approach This paper investigates a novel debugging technique called out-of-place debugging. The goal is to minimize the debugging interference characteristic of online debugging while allowing online remote ca- pabilities. An out-of-place debugger transfers the program execution and application state from the debugged application to the debugger application, each running in a different process. Knowledge On the one hand, out-of-place debugging allows developers to debug applications remotely, overcoming the need of physical access to the machine where the debugged application is running. On the other hand, debugging happens locally on the remote machine avoiding latency. That makes it suitable to be deployed on a distributed system and handle the debugging of several processes running in parallel. Grounding We implemented a concrete out-of-place debugger for the Pharo Smalltalk programming lan- guage. We show that our approach is practical by running several benchmarks, comparing our approach with a classic remote online debugger. We show that our prototype debugger outperforms a traditional remote debugger by 1000 times in several scenarios. Moreover, we show that the presence of our debugger does not impact the overall performance of an application. Importance This work combines remote debugging with the debugging experience of a local online debug- ger. Out-of-place debugging is the first online debugging technique that can minimize debugging interference while debugging a remote application. Yet, it still keeps the benefits of online debugging (e.g., step-by-step execution). This makes the technique suitable for modern applications which are increasingly parallel, dis- tributed and reactive to streams of data from various sources like sensors, UI, network, etc. ACM CCS 2012 Software and its engineering → Software testing and debugging; Keywords debugging tools, online debugging, remote debugging, distributed systems The Art, Science, and Engineering of Programming Submitted December 1, 2017 Published November 7, 2018 doi 10.22152/programming-journal.org/2019/3/3 © Matteo Marra, Guillermo Polito, and Elisa Gonzalez Boix This work is licensed under a “CC BY-NC 4.0” license. In The Art, Science, and Engineering of Programming, vol. 3, no. 2, 2019, article 3; 29 pages. Out-Of-Place debugging: a debugging architecture to reduce debugging interference 1 Introduction Debugging is one of the main activities in the development of modern applications [17]. A recent study conducted by Cambridge showed that most of the programming time is nowadays spent on testing, verifying and debugging software [4]. As software gets more complex, bugs get more sophisticated. Many difficulties raise when debugging parallel programs [30]. For instance, bugs may be caused by a particular interaction between many parallel components, or seen sporadically in concurrent processes. Understanding, replicating and solving such bugs is a challenging task that might take quite a lot of time and resources. Over the years several techniques were proposed to aid developers in the arduous task of debugging (section 2). In particular, there exist two well-known families of debuggers: online and offline debuggers [25, 30]. Online debuggers control theexe- cution of an application at the moment of a failure. They allow developers to interact smoothly with the target application, offering stepping and breakpoint operations that give immediate feedback to the developer. On the other hand, offline debuggers (or post-mortem debuggers) try to reconstruct the context of a bug once the process that failed is already finished. Such solutions analyse or replay log files, code dumps and/or execution traces to help the developer discover the source of the problem. Re- producing a bug with these techniques can be tedious and time-consuming, especially because many debugging cycles are required before the error happens again. Online solutions provide good insight into the conditions that led to a bug since they allow developers to inspect the state of the application, and to interact with it through the evaluation of expressions. However, online debuggers introduce debugging inter- ference (also known as the probe effect [25])1 due to the communication of processes and the performance penalties introduced by the debugging infrastructure. Such interference alters the behaviour of the application and makes a bug more difficult to reproduce during debugging.2 Contribution In this paper we present a novel debugging technique called out-of- place debugging (section 3). The goal is to combine the benefits of local and remote debugging, providing the latency of a local debugger while allowing developers to debug remote applications and scoping eventual side effects. When the debugged application is paused in a breakpoint or an exception, the execution stack and the application state are entirely transferred to the (remote) out-of-place debugger. The developer then proceeds to debug the application locally, with an entire copy of the program state. In this paper, we show the benefits of out-of-place debugging in terms of reduced latency and scoping of side effects, in different debugging scenarios. We also present our implementation of IDRA, a prototype of out-of-place debugger in Pharo Smalltalk. 1 Debugging interference is also known in computer science as the the observer effect. This states that an observer modifies the observed object while observing it. 2 A bug that disappears during debugging it is also known as a heisenbug. 3:2 Matteo Marra, Guillermo Polito, and Elisa Gonzalez Boix We show that the presence of our debugger does not impact application performance during normal execution. We also show that our prototype debugger performs better than a traditional remote debugger in some scenarios and can improve the debugging experience. 2 Motivation To show the kind of problems that arise while debugging modern applications, we introduce two debugging scenarios: (1) a distributed and parallel application that analyzes tweets and (2) a cyber physical system (CPS) that is remotely deployed and listening to data coming from a sensor. 2.1 Debugging Scenario 1: Twitter application Let us consider a distributed application that continuously analyzes tweets coming from a stream. For the purposes of this presentation, the relevant code of such an application is illustrated in listing 1. There are two methods: analyzeTweets that consumes a stream of tweets and processTweet: that creates a dictionary mapping each word occurring in the tweet with the number of occurrences in the tweet. Listing 1 A simple tweet consuming application 1 TwitterApplication>>analyzeTweets 2 | results | 3 results := OrderedCollection new. 4 [ twitterStream hasNext ] whileTrue: [ | tweet | 5 tweet := twitterStream next. 6 results nextPut: (self processTweet: tweet). 7 ] 8 self mergeDictionaries: results. 9 " 10 TwitterApplication>>processTweet: aTweet 11 | wordCount tweetObject text words | 12 tweetObject := self parseTweet: aTweet. 13 text := tweetObject text. 14 words := text findTokens. 15 wordCount := Dictionary new. 16 words do: [ :word | 17 (wordCount includesKey: word) 18 ifTrue: [ wordCount at: word put: 1+ (result at: word) ] 19 ifFalse: [ wordCount at: word put: 1] ]. 20 result " At first glance, the code looks correct and on the developer’s local machine thecode runs without problems. Now consider the same application deployed on a cluster, executed in parallel. In this scenario, the distributed setup makes it even more difficult to track bugs. 3:3 Out-Of-Place debugging: a debugging architecture to reduce debugging interference Concretely in this case, if the application is left running for hours or even days, depending on the number of tweets in the stream, an out-of-memory error happens. Our twitter stream is optimized with a read buffer to read and allocate memory in chunks of more optimal sizes. The developer that designed the buffering optimiza- tion accidentally introduced a bug: the buffered objects are not correctly released, generating a memory leak. Understanding the root cause of the problem is not an easy task. First, it is not easy to reproduce the conditions that make the bug appear. Even reproducing it in a production environment may take quite a long time for the error to appear. Second, the developer needs to perform several debugging cycles before finding the actual cause of the bug. 2.2 Debugging scenario 2: A temperature monitoring application Another common scenario