-
Notifications
You must be signed in to change notification settings - Fork 134
Description
Proposed change: For a given code generation pass, we'd get the call tree annotated with the time spent in each function. For instance, if codegen_items calls codegen_function, which calls codegen_statement n times, etc., we'd get the time we spent in each of those calls, down to the end of the call tree. I'm imagining we'd visualize it as a tree because the depth of the call stack is also important, but I'm flexible on the format; the main point is getting data on how long different parts of codegen take, not just codegen as a whole.
Motivation: From some rudimentary benchmarking with with_timer:
kani/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs
Lines 831 to 833 in 2227614
| /// Execute the provided function and measure the clock time it took for its execution. | |
| /// Log the time with the given description. | |
| pub fn with_timer<T, F>(func: F, description: &str) -> T |
we've determined that most of Kani's compiler runtime comes from code generation. But we need more fine-grained data to know why code generation is slow. Currently, it's unclear whether:
- Most functions are fast enough, but there are specific outliers we can blame, e.g., if codegening a function with fat pointers or dynamic dispatch is much slower than codegening functions without, or
- Most functions are fast enough in isolation, but we have a deep call tree so their cumulative time is slow, suggesting that we need a larger-scale refactoring to produce speedups, or at least small-scale optimizations of multiple functions.
Having this data would help us make that determination.