| 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 | \todo{Revisit organization of the performance chapter once tests are chosen.}
|
|---|
| 7 | % What are good tests for resumption?
|
|---|
| 8 |
|
|---|
| 9 | Performance has been of secondary importance for most of this project.
|
|---|
| 10 | Instead, the focus has been to get the features working. The only performance
|
|---|
| 11 | requirements is to ensure the tests for correctness run in a reasonable
|
|---|
| 12 | amount of time.
|
|---|
| 13 |
|
|---|
| 14 | %\section{Termination Comparison}
|
|---|
| 15 | \section{Test Set-Up}
|
|---|
| 16 | Tests will be run on \CFA, C++ and Java.
|
|---|
| 17 |
|
|---|
| 18 | C++ is the most comparable language because both it and \CFA use the same
|
|---|
| 19 | framework, libunwind.
|
|---|
| 20 | In fact, the comparison is almost entirely a quality of implementation
|
|---|
| 21 | comparison. \CFA's EHM has had significantly less time to be optimized and
|
|---|
| 22 | does not generate its own assembly. It does have a slight advantage in that
|
|---|
| 23 | there are some features it does not handle.
|
|---|
| 24 |
|
|---|
| 25 | Java is another very popular language with similar termination semantics.
|
|---|
| 26 | It is implemented in a very different environment, a virtual machine with
|
|---|
| 27 | garbage collection.
|
|---|
| 28 | It also implements the finally clause on try blocks allowing for a direct
|
|---|
| 29 | feature-to-feature comparison.
|
|---|
| 30 |
|
|---|
| 31 | All tests are run inside a main loop which will perform the test
|
|---|
| 32 | repeatedly. This is to avoids start-up or tear-down time from
|
|---|
| 33 | affecting the timing results.
|
|---|
| 34 | A consequence of this is that tests cannot terminate the program,
|
|---|
| 35 | which does limit how tests can be implemented.
|
|---|
| 36 | There are catch-alls to keep unhandled
|
|---|
| 37 | exceptions from terminating tests.
|
|---|
| 38 |
|
|---|
| 39 | The exceptions used in these tests will always be a exception based off of
|
|---|
| 40 | the base exception. This requirement minimizes performance differences based
|
|---|
| 41 | on the object model.
|
|---|
| 42 | Catch-alls are done by catching the root exception type (not using \Cpp's
|
|---|
| 43 | \code{C++}{catch(...)}).
|
|---|
| 44 |
|
|---|
| 45 | Tests run in Java were not warmed because exception code paths should not be
|
|---|
| 46 | hot.
|
|---|
| 47 |
|
|---|
| 48 | \section{Tests}
|
|---|
| 49 | The following tests were selected to test the performance of different
|
|---|
| 50 | components of the exception system.
|
|---|
| 51 | The should provide a guide as to where the EHM's costs can be found.
|
|---|
| 52 |
|
|---|
| 53 | \paragraph{Raise/Handle}
|
|---|
| 54 | What is the basic cost to raise and handle an exception?
|
|---|
| 55 |
|
|---|
| 56 | There are a number of factors that can effect this.
|
|---|
| 57 | For \CFA this includes the type of raise,
|
|---|
| 58 |
|
|---|
| 59 | Main loop, pass through a catch-all, call through some empty helper functions
|
|---|
| 60 | to put frames on the stack then raise and exception.
|
|---|
| 61 | \todo{Raise/Handle (or a similar test) could also test how much it costs to
|
|---|
| 62 | search over things, not sure if that is a useful test.}
|
|---|
| 63 |
|
|---|
| 64 | \paragraph{Unwinding}
|
|---|
| 65 | Isolating the unwinding of the stack as much as possible.
|
|---|
| 66 |
|
|---|
| 67 | This has the same set-up as the raise/handle test except the intermediate
|
|---|
| 68 | stack frames contain either an object declaration with a destructor or a
|
|---|
| 69 | try statement with no handlers except for a finally clause.
|
|---|
| 70 |
|
|---|
| 71 | \paragraph{Enter/Leave}
|
|---|
| 72 | What is the cost of entering and leaving a try block, even if no exception
|
|---|
| 73 | is thrown?
|
|---|
| 74 |
|
|---|
| 75 | This test is a simple pattern of entering
|
|---|
| 76 | and leaving a try statement.
|
|---|
| 77 |
|
|---|
| 78 | The only tunables here are which clauses are attached to the try block:
|
|---|
| 79 | termination handlers, resumption handlers and finally clauses.
|
|---|
| 80 |
|
|---|
| 81 | \paragraph{Re-throw and Conditional-Catch}
|
|---|
| 82 | How expensive it is to run a non-exception type check for a handler?
|
|---|
| 83 |
|
|---|
| 84 | In this case different languages approach this problem differently, either
|
|---|
| 85 | through a re-throw or a conditional-catch.
|
|---|
| 86 | Where \CFA uses its condition other languages will have to unconditionally
|
|---|
| 87 | catch the exception then re-throw if the condition if the condition is false.
|
|---|
| 88 |
|
|---|
| 89 | The set up is as follows: main loop, a catch-all exception handler,
|
|---|
| 90 | a conditional catch and then the raise.
|
|---|
| 91 |
|
|---|
| 92 | % We could do a Cforall test without the catch all and a new default handler
|
|---|
| 93 | % that does a catch all.
|
|---|
| 94 | As a point of comparison one of the raise/handle tests (which one?) has
|
|---|
| 95 | same layout but never catches anything.
|
|---|
| 96 |
|
|---|
| 97 | The main tunable in this test is how often the conditional-catch matches.
|
|---|
| 98 |
|
|---|
| 99 | %\section{Cost in Size}
|
|---|
| 100 | %Using exceptions also has a cost in the size of the executable.
|
|---|
| 101 | %Although it is sometimes ignored
|
|---|
| 102 | %
|
|---|
| 103 | %There is a size cost to defining a personality function but the later problem
|
|---|
| 104 | %is the LSDA which will be generated for every function.
|
|---|
| 105 | %
|
|---|
| 106 | %(I haven't actually figured out how to compare this, probably using something
|
|---|
| 107 | %related to -fexceptions.)
|
|---|
| 108 |
|
|---|
| 109 | % Some languages I left out:
|
|---|
| 110 | % Python: Its a scripting language, different
|
|---|
| 111 | % uC++: Not well known and should the same results as C++, except for
|
|---|
| 112 | % resumption which should be the same.
|
|---|
| 113 |
|
|---|
| 114 | %\section{Resumption Comparison}
|
|---|
| 115 | \todo{Can we find a good language to compare resumptions in.}
|
|---|