Commit c29b906
authored
Share body cache between harnesses within a codegen unit (#4276)
Improves on #4259 by fully sharing the body cache between harnesses in
the same codegen unit.
This cache initially only stored bodies which had been modified by our
transformations, with the goal being to avoid doing those
transformations multiple times. It does this job well, having a hit rate
of **~66% on queries for modified bodies**[^1].
However, I observed that even just querying to get the initial `Body`
for a given `Instance` was a bottleneck, even if no passes needed to be
applied. And, in this regard, the cache is much less effective, having a
hit rate of **only 1.8% if you count non-modified bodies**[^1].
Thus, this PR also _adds all bodies to the cache, even those which were
not modified_ by our passes.
### Results
This change causes a further **7.7% reduction in the end to end compile
time** of the standard library (@ commit
[177d0fd](model-checking/verify-rust-std@177d0fd)).
The body cache has an **average hit rate of 95.3%** on that workload
and, on a hit, we (at most) have to do an inexpensive clone from the
cache rather than querying `rustc_public`.
As a caching solution, this comes with some memory overhead. Since we're
sharing a cache and caching more bodies, the peak size of this cache has
gone from **0.88 MB to 3.75 MB**. This may seem like a significant
increase (and I'm definitely open to feedback on whether it's
acceptable), but given the fact that Kani hovered around 2.5-3.5 GB of
RAM for that same run, this bigger cache would make up just 0.11%-0.15%
of our total memory use.
[^1]: when verifying the standard library (@ commit
[177d0fd](model-checking/verify-rust-std@177d0fd))
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.1 parent 2b05737 commit c29b906
File tree
25 files changed
+91
-101
lines changed- kani-compiler/src
- codegen_cprover_gotoc
- codegen
- context
- utils
- kani_middle
- transform
- check_uninit/delayed_ub
25 files changed
+91
-101
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments