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 | The driving for has been to get the features working, the only performance |
---|
9 | requirements were to make sure the tests for correctness rain in a reasonable |
---|
10 | amount of time. |
---|
11 | Still this is an implementation others could use for similar prototypes and |
---|
12 | so the results still have some use. |
---|
13 | |
---|
14 | \section{Test Set-Up} |
---|
15 | Tests will be run on \CFA, C++ and Java. |
---|
16 | |
---|
17 | C++ is the most comparable language because both it and \CFA use the same |
---|
18 | framework, libunwind. |
---|
19 | In fact the comparison is almost entirely a quality of implementation |
---|
20 | comparison. \CFA's EHM has had significantly less time to be optimized and |
---|
21 | does not generate its own assembly. It does have a slight advantage in that |
---|
22 | there are some features it does not handle. |
---|
23 | |
---|
24 | % Some languages I left out: |
---|
25 | % Python: Its a scripting language, different |
---|
26 | % uC++: Not well known and should the same results as C++, except for |
---|
27 | % resumption which should be the same. |
---|
28 | \todo{Can we find a good language to compare resumptions in.} |
---|
29 | |
---|
30 | All tests will be run inside a main loop which will perform the test |
---|
31 | repeatedly. This is to avoid letting and start-up or tear-down time from |
---|
32 | affecting the timing results. |
---|
33 | This also means 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 the program. |
---|
36 | |
---|
37 | The exceptions used in this test will always be a new exception based off of |
---|
38 | the base exception. This should minimize and preformance differences based |
---|
39 | on the object model. |
---|
40 | Catch-alls will be 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 | \section{Tests} |
---|
47 | \paragraph{Raise/Handle} |
---|
48 | What is the basic cost to raise and handle an exception? |
---|
49 | |
---|
50 | There are a number of factors that can effect this, for \CFA this includes |
---|
51 | the type of raise, |
---|
52 | |
---|
53 | Main loop, pass through a catch-all, call through some empty helper functions |
---|
54 | to put frames on the stack then raise and exception. |
---|
55 | \todo{Raise/Handle (or a similar test) could also test how much it costs to |
---|
56 | search over things, not sure if that is a useful test.} |
---|
57 | |
---|
58 | \paragraph{Unwinding} |
---|
59 | Isolating the unwinding of the stack as much as possible. |
---|
60 | |
---|
61 | This has the same set-up as the raise/handle test except the intermediate |
---|
62 | stack frames contain either an object declaration with a destructor or a |
---|
63 | try statement with no handlers except for a finally clause. |
---|
64 | |
---|
65 | \paragraph{Enter/Leave} |
---|
66 | What is the cost of entering and leaving a try block, even if no exception |
---|
67 | is thrown? |
---|
68 | |
---|
69 | This is the simplist pattern to test as it is a simple matter of entering |
---|
70 | and leaving a try statement. |
---|
71 | |
---|
72 | The only tunables here are which clauses are attached to the try block: |
---|
73 | termination handlers, resumption handlers and finally clauses. |
---|
74 | |
---|
75 | \paragraph{Re-throw and Conditional-Catch} |
---|
76 | How expencive it is to run a non-exception type check for a handler? |
---|
77 | |
---|
78 | In this case different languages approach this problem differently, either |
---|
79 | through a re-throw or a conditional-catch. |
---|
80 | Where \CFA uses its condition other languages will have to unconditionally |
---|
81 | catch the exception then re-throw if the condition if the condition is false. |
---|
82 | |
---|
83 | The set up is as follows: main loop, a catch-all exception handler, |
---|
84 | a conditional catch and then the raise. |
---|
85 | |
---|
86 | % We could do a Cforall test without the catch all and a new default handler |
---|
87 | % that does a catch all. |
---|
88 | As a point of comparison one of the raise/handle tests (which one?) has |
---|
89 | same layout but never catches anything. |
---|
90 | |
---|
91 | The main tunable in this test is how often the conditional-catch matches. |
---|
92 | |
---|
93 | %\section{Cost in Size} |
---|
94 | %Using exceptions also has a cost in the size of the executable. |
---|
95 | %Although it is sometimes ignored |
---|
96 | % |
---|
97 | %There is a size cost to defining a personality function but the later problem |
---|
98 | %is the LSDA which will be generated for every function. |
---|
99 | % |
---|
100 | %(I haven't actually figured out how to compare this, probably using something |
---|
101 | %related to -fexceptions.) |
---|