Commit 6dc3205
committed
Rule 8.7: Improve performance
This rule was identified as containing one of the slowest predicates in
our C Coding Standards query suites, and this commit improves the
performance.
Performance is improved with the following changes:
(a) Factoring out a predicate for the repeated calls to getTarget(), to
avoid duplication and to create a semantically meaningful predicate
which gets the target for a reference to an external identifier.
(b) Use the factored out predicate to refine the reference class to
only be references to external identifiers. This reduces the size
of the class.
(c) Create a predicate for computing a table of external identifiers,
references to those identifiers and the translation units those
exist in. We can then compute this table once, and use it in both
the "find me a reference to this external identifier" case and in
the "where the external identifier is not referenced in any other
translation unit" case.
Part (c) is the critical change. Without that, the optimizer was
creating an expensive join order in the negation case, where it
was effectively creating a cross product of all references to each
external identifier, before later excluding on the negation. The use
of our predicate in the negation case means we can first create a table
of external identifiers and translation units, then apply that in the
negation case without cross producting the references.1 parent 917c62e commit 6dc3205
File tree
1 file changed
+24
-15
lines changed- c/misra/src/rules/RULE-8-7
1 file changed
+24
-15
lines changedLines changed: 24 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | | - | |
25 | | - | |
| 30 | + | |
26 | 31 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
32 | 43 | | |
33 | 44 | | |
34 | | - | |
| 45 | + | |
35 | 46 | | |
36 | 47 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
44 | 53 | | |
45 | 54 | | |
46 | 55 | | |
0 commit comments