You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid updating irrelevant symbols when handling quantifiers (#4268)
Kani currently has a special `handle_quantifiers()` pass after codegen
that we need to recursively inline function calls inside quantifier
expressions as needed by our hooks. This has to be done for every value
in the symbol table, but our current implementation implicitly clones
**all `Stmt` type values**, even if they don't contain any quantifiers
and wouldn't need to change. This makes the pass currently take up **~7%
of codegen on crates that don't even use quantifiers**.
Now, the `handle_quantifiers_in_stmt()` function just returns an option
with a new `Stmt` if inlining was needed, or `None` otherwise, allowing
us to avoid any allocations and even needing to insert back into the
table in the common case where a `Stmt` doesn't contain any quantifiers.
### Results
Flamegraphing shows that this change reduces the `handle_quantifiers()`
pass from 7.1% to just 0.8% of codegen for the `s2n-codec` crate.
There was a much less significant change on larger codebases like the
standard library, which only saw **a <1% improvement in end to end
compile time** (at std commit
[177d0fd](model-checking/verify-rust-std@177d0fd),
assuming #4257 & #4259 are merged into Kani). That being said, there was
a significant **1-7% decrease in codegen time** for individual crates of
the standard library, so it seems to still make a difference, even if
not reflected in e2e time.
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
0 commit comments