-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor binaryop/compiled/util.cpp (#10756)
This PR reduces the complexity of compile-time dispatches to resolve long compile times and massive memory usage in `binaryop/compiled.util.cpp`. The file `binaryop/compiled/util.cpp` exposes two functions: `is_supported_operation(out, lhs, rhs, op)` and `get_common_type(out, lhs, rhs)`. I refactored both of them, since they were both expensive to compile. In `is_supported_operation`, I replaced a quadruple dispatch (!!!!) on (LHS type, RHS type, binary operation, output type) with a triple dispatch (LHS type, RHS type, BinaryOp) and some runtime single-dispatches to handle the output type. In `get_common_type`, I replaced a triple type dispatch on (output type, LHS type, RHS type) with a few double type dispatches. I used the definition of `std::common_type` to simplify `std::common_type_t<A, B, C>` into `std::common_type_t<std::common_type_t<A, B>, C>`, which means we can double-dispatch twice and use runtime `data_type` values in between. **Impact:** Peak memory usage (max resident set size) when compiling this file drops from 14.6 GB (280acdf) to 2.4 GB (ee2c26a), and the time to compile drops from 2:52.48 minutes (280acdf) to 57.91 seconds (ee2c26a). Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Karthikeyan (https://github.com/karthikeyann) URL: #10756
- Loading branch information
Showing
1 changed file
with
98 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters