[dac16a0] | 1 | \chapter{Performance}
|
---|
| 2 | \label{c:performance}
|
---|
| 3 |
|
---|
| 4 | \textbf{Just because of the stage of testing there are design notes for
|
---|
| 5 | the tests as well as commentary on them.}
|
---|
| 6 |
|
---|
| 7 | Performance has been of secondary importance for most of this project.
|
---|
[029cbc0] | 8 | Instead, the focus has been to get the features working. The only performance
|
---|
| 9 | requirements is to ensure the tests for correctness run in a reasonable
|
---|
[dac16a0] | 10 | amount of time.
|
---|
[b51e389c] | 11 |
|
---|
| 12 | \section{Test Set-Up}
|
---|
| 13 | Tests will be run on \CFA, C++ and Java.
|
---|
[dac16a0] | 14 |
|
---|
| 15 | C++ is the most comparable language because both it and \CFA use the same
|
---|
| 16 | framework, libunwind.
|
---|
[029cbc0] | 17 | In fact, the comparison is almost entirely a quality of implementation
|
---|
[dac16a0] | 18 | comparison. \CFA's EHM has had significantly less time to be optimized and
|
---|
| 19 | does not generate its own assembly. It does have a slight advantage in that
|
---|
| 20 | there are some features it does not handle.
|
---|
| 21 |
|
---|
[029cbc0] | 22 | Java is another very popular language with similar termination semantics.
|
---|
| 23 | It is implemented in a very different environment, a virtual machine with
|
---|
| 24 | garbage collection.
|
---|
| 25 | It also implements the finally clause on try blocks allowing for a direct
|
---|
| 26 | feature-to-feature comparison.
|
---|
[dac16a0] | 27 |
|
---|
[029cbc0] | 28 | All tests are run inside a main loop which will perform the test
|
---|
| 29 | repeatedly. This is to avoids start-up or tear-down time from
|
---|
[dac16a0] | 30 | affecting the timing results.
|
---|
[029cbc0] | 31 | A consequence of this is that tests cannot terminate the program,
|
---|
| 32 | which does limit how tests can be implemented.
|
---|
| 33 | There are catch-alls to keep unhandled
|
---|
| 34 | exceptions from terminating tests.
|
---|
[dac16a0] | 35 |
|
---|
[029cbc0] | 36 | The exceptions used in these tests will always be a exception based off of
|
---|
| 37 | the base exception. This requirement minimizes performance differences based
|
---|
[dac16a0] | 38 | on the object model.
|
---|
[029cbc0] | 39 | Catch-alls are done by catching the root exception type (not using \Cpp's
|
---|
[dac16a0] | 40 | \code{C++}{catch(...)}).
|
---|
| 41 |
|
---|
| 42 | Tests run in Java were not warmed because exception code paths should not be
|
---|
| 43 | hot.
|
---|
| 44 |
|
---|
[b51e389c] | 45 | \section{Tests}
|
---|
[029cbc0] | 46 | The following tests were selected to test the performance of different
|
---|
| 47 | components of the exception system.
|
---|
| 48 | The should provide a guide as to where the EHM's costs can be found.
|
---|
| 49 |
|
---|
[ea593a3] | 50 | Tests are run in \CFA, \Cpp and Java.
|
---|
| 51 | Not every test is run in every language, if the feature under test is missing
|
---|
| 52 | the test is skipped. These cases will be noted.
|
---|
| 53 | In addition to the termination tests for every language,
|
---|
| 54 | \CFA has a second set of tests that test resumption. These are the same
|
---|
| 55 | except that the raise statements and handler clauses are replaced with the
|
---|
| 56 | resumption variants.
|
---|
| 57 |
|
---|
| 58 | \paragraph{Raise and Handle}
|
---|
| 59 | The first group of tests involve setting up
|
---|
| 60 | So there is three layers to the test. The first is set up and a loop, which
|
---|
| 61 | configures the test and then runs it repeatedly to reduce the impact of
|
---|
| 62 | start-up and shutdown on the results.
|
---|
| 63 | Each iteration of the main loop
|
---|
| 64 | \begin{itemize}
|
---|
| 65 | \item Empty Function:
|
---|
| 66 | The repeating function is empty except for the necessary control code.
|
---|
| 67 | \item Destructor:
|
---|
| 68 | The repeating function creates an object with a destructor before calling
|
---|
| 69 | itself.
|
---|
| 70 | (Java is skipped as it does not destructors.)
|
---|
| 71 | \item Finally:
|
---|
| 72 | The repeating function calls itself inside a try block with a finally clause
|
---|
| 73 | attached.
|
---|
| 74 | (\Cpp is skipped as it does not have finally clauses.)
|
---|
| 75 | \item Other Handler:
|
---|
| 76 | The repeating function calls itself inside a try block with a handler that
|
---|
| 77 | will not match the raised exception. (But is of the same kind of handler.)
|
---|
| 78 | \end{itemize}
|
---|
| 79 |
|
---|
| 80 | \paragraph{Cross Try Statement}
|
---|
| 81 | The next group measures the cost of a try statement when no exceptions are
|
---|
| 82 | raised. The test is set-up, then there is a loop to reduce the impact of
|
---|
| 83 | start-up and shutdown on the results.
|
---|
| 84 | In each iteration, a try statement is executed. Entering and leaving a loop
|
---|
| 85 | is all the test wants to do.
|
---|
| 86 | \begin{itemize}
|
---|
| 87 | \item Handler:
|
---|
| 88 | The try statement has a handler (of the matching kind).
|
---|
| 89 | \item Finally:
|
---|
| 90 | The try statement has a finally clause.
|
---|
| 91 | \end{itemize}
|
---|
| 92 |
|
---|
| 93 | \paragraph{Conditional Matching}
|
---|
| 94 | This group of tests checks the cost of conditional matching.
|
---|
| 95 | Only \CFA implements the language level conditional match,
|
---|
| 96 | the other languages must mimic with an ``unconditional" match (it still
|
---|
| 97 | checks the exception's type) and conditional re-raise.
|
---|
| 98 | \begin{itemize}
|
---|
| 99 | \item Catch All:
|
---|
| 100 | The condition is always true. (Always matches or never re-raises.)
|
---|
| 101 | \item Catch None:
|
---|
| 102 | The condition is always false. (Never matches or always re-raises.)
|
---|
| 103 | \end{itemize}
|
---|
[dac16a0] | 104 |
|
---|
| 105 | %\section{Cost in Size}
|
---|
| 106 | %Using exceptions also has a cost in the size of the executable.
|
---|
| 107 | %Although it is sometimes ignored
|
---|
| 108 | %
|
---|
| 109 | %There is a size cost to defining a personality function but the later problem
|
---|
| 110 | %is the LSDA which will be generated for every function.
|
---|
| 111 | %
|
---|
| 112 | %(I haven't actually figured out how to compare this, probably using something
|
---|
| 113 | %related to -fexceptions.)
|
---|
[029cbc0] | 114 |
|
---|
| 115 | % Some languages I left out:
|
---|
| 116 | % Python: Its a scripting language, different
|
---|
| 117 | % uC++: Not well known and should the same results as C++, except for
|
---|
| 118 | % resumption which should be the same.
|
---|
| 119 |
|
---|
| 120 | %\section{Resumption Comparison}
|
---|
| 121 | \todo{Can we find a good language to compare resumptions in.}
|
---|