Skip to content

Commit 7bea7db

Browse files
authored
Speed up predicate splitting during module lowering (#532)
1 parent 73810cb commit 7bea7db

5 files changed

Lines changed: 255 additions & 115 deletions

File tree

src/lang/frontend_ast_lower.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,26 @@ impl<'a> Lowerer<'a> {
550550

551551
// Apply splitting to each predicate as needed. The typed-key rewrite
552552
// happens before splitting so split chain pieces inherit `Index` keys
553-
// unchanged.
553+
// unchanged. The search cache is shared across the module: modules
554+
// routinely contain families of same-shape predicates, which then
555+
// pay for the ordering search once.
556+
let split_started = std::time::Instant::now();
557+
let mut search_cache = frontend_ast_split::SplitSearchCache::default();
554558
let mut split_results = Vec::new();
555559
for mut pred in predicates {
556560
self.rewrite_typed_dot_access(&mut pred);
557-
let result = frontend_ast_split::split_predicate_if_needed(pred, self.params)?;
561+
let result = frontend_ast_split::split_predicate_if_needed(
562+
pred,
563+
self.params,
564+
&mut search_cache,
565+
)?;
558566
split_results.push(result);
559567
}
568+
log::debug!(
569+
"predicate splitting: {:?} ({} predicates)",
570+
split_started.elapsed(),
571+
split_results.len(),
572+
);
560573

561574
Ok(split_results)
562575
}

0 commit comments

Comments
 (0)