\chapter{Performance} \label{c:performance} \textbf{Just because of the stage of testing there are design notes for the tests as well as commentary on them.} \todo{Revisit organization of the performance chapter once tests are chosen.} % What are good tests for resumption? Performance has been of secondary importance for most of this project. Instead, the focus has been to get the features working. The only performance requirements is to ensure the tests for correctness run in a reasonable amount of time. %\section{Termination Comparison} \section{Test Set-Up} Tests will be run on \CFA, C++ and Java. C++ is the most comparable language because both it and \CFA use the same framework, libunwind. In fact, the comparison is almost entirely a quality of implementation comparison. \CFA's EHM has had significantly less time to be optimized and does not generate its own assembly. It does have a slight advantage in that there are some features it does not handle. Java is another very popular language with similar termination semantics. It is implemented in a very different environment, a virtual machine with garbage collection. It also implements the finally clause on try blocks allowing for a direct feature-to-feature comparison. All tests are run inside a main loop which will perform the test repeatedly. This is to avoids start-up or tear-down time from affecting the timing results. A consequence of this is that tests cannot terminate the program, which does limit how tests can be implemented. There are catch-alls to keep unhandled exceptions from terminating tests. The exceptions used in these tests will always be a exception based off of the base exception. This requirement minimizes performance differences based on the object model. Catch-alls are done by catching the root exception type (not using \Cpp's \code{C++}{catch(...)}). Tests run in Java were not warmed because exception code paths should not be hot. \section{Tests} The following tests were selected to test the performance of different components of the exception system. The should provide a guide as to where the EHM's costs can be found. \paragraph{Raise/Handle} What is the basic cost to raise and handle an exception? There are a number of factors that can effect this. For \CFA this includes the type of raise, Main loop, pass through a catch-all, call through some empty helper functions to put frames on the stack then raise and exception. \todo{Raise/Handle (or a similar test) could also test how much it costs to search over things, not sure if that is a useful test.} \paragraph{Unwinding} Isolating the unwinding of the stack as much as possible. This has the same set-up as the raise/handle test except the intermediate stack frames contain either an object declaration with a destructor or a try statement with no handlers except for a finally clause. \paragraph{Enter/Leave} What is the cost of entering and leaving a try block, even if no exception is thrown? This test is a simple pattern of entering and leaving a try statement. The only tunables here are which clauses are attached to the try block: termination handlers, resumption handlers and finally clauses. \paragraph{Re-throw and Conditional-Catch} How expensive it is to run a non-exception type check for a handler? In this case different languages approach this problem differently, either through a re-throw or a conditional-catch. Where \CFA uses its condition other languages will have to unconditionally catch the exception then re-throw if the condition if the condition is false. The set up is as follows: main loop, a catch-all exception handler, a conditional catch and then the raise. % We could do a Cforall test without the catch all and a new default handler % that does a catch all. As a point of comparison one of the raise/handle tests (which one?) has same layout but never catches anything. The main tunable in this test is how often the conditional-catch matches. %\section{Cost in Size} %Using exceptions also has a cost in the size of the executable. %Although it is sometimes ignored % %There is a size cost to defining a personality function but the later problem %is the LSDA which will be generated for every function. % %(I haven't actually figured out how to compare this, probably using something %related to -fexceptions.) % Some languages I left out: % Python: Its a scripting language, different % uC++: Not well known and should the same results as C++, except for % resumption which should be the same. %\section{Resumption Comparison} \todo{Can we find a good language to compare resumptions in.}