From 7aeb5a30c469c01ee00a3f64ff09d2bff43e81be Mon Sep 17 00:00:00 2001 From: Aria Shrimpton Date: Fri, 8 Mar 2024 17:49:30 +0000 Subject: adaptive suggestion fixes --- src/crates/candelabra/src/profiler/info.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/crates/candelabra/src/profiler/info.rs b/src/crates/candelabra/src/profiler/info.rs index cde1e2c..78ce299 100644 --- a/src/crates/candelabra/src/profiler/info.rs +++ b/src/crates/candelabra/src/profiler/info.rs @@ -108,12 +108,10 @@ impl UsageProfile { // calculate cost of switching let before = &top_by_partition[0].0; let after = &top_by_partition[split_idx].0; - let before_model = candidates.get(before).unwrap(); - let after_model = candidates.get(after).unwrap(); let copy_n = self.0[split_idx].avg_n; - let switching_cost = after_model.by_op.get("insert")?.estimatef(copy_n) - + before_model.by_op.get("clear")?.estimatef(copy_n); + let after_model = candidates.get(after).unwrap(); + let switching_cost = copy_n * after_model.by_op.get("insert")?.estimatef(copy_n / 2.0); // see if it's "worth it" let before_costs = &costs_by_partitions @@ -141,7 +139,7 @@ impl UsageProfile { threshold: copy_n as usize, after: after.to_string(), }, - top_by_partition.iter().map(|(_, v)| v).sum(), + top_by_partition.iter().map(|(_, v)| v).sum::() + switching_cost, )) } } -- cgit v1.2.3