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