formualizer_eval/engine/
tuning.rs

1//! Warmup configuration and tuning parameters
2
3/// Configuration for global pass warmup
4#[derive(Clone, Debug)]
5pub struct WarmupConfig {
6    // Control
7    pub warmup_enabled: bool,
8    pub warmup_time_budget_ms: u64,
9    pub warmup_parallelism_cap: usize,
10
11    // Selection limits
12    pub warmup_topk_refs: usize,
13    pub warmup_topk_criteria_sets: usize,
14
15    // Thresholds for when to build artifacts
16    pub min_flat_cells: usize,
17    pub min_mask_cells: usize,
18    pub min_index_rows: usize,
19
20    // Reuse thresholds
21    pub flat_reuse_threshold: usize,
22    pub mask_reuse_threshold: usize,
23    pub index_reuse_threshold: usize,
24
25    // Memory budgets
26    pub flat_cache_mb_cap: usize,
27    pub mask_cache_entries_cap: usize,
28    pub index_memory_budget_mb: usize,
29}
30
31impl Default for WarmupConfig {
32    fn default() -> Self {
33        Self {
34            // Enabled by default: warmup executes at evaluation time with conservative budgets
35            warmup_enabled: false,
36            warmup_time_budget_ms: 250,
37            warmup_parallelism_cap: 4,
38
39            // Conservative selection limits
40            warmup_topk_refs: 10,
41            warmup_topk_criteria_sets: 10,
42
43            // Conservative thresholds to avoid overhead on small data
44            min_flat_cells: 1000,
45            min_mask_cells: 1000,
46            min_index_rows: 10000,
47
48            // Require multiple uses to justify caching
49            flat_reuse_threshold: 3,
50            mask_reuse_threshold: 3,
51            index_reuse_threshold: 5,
52
53            // Reasonable memory limits
54            flat_cache_mb_cap: 100,
55            mask_cache_entries_cap: 1000,
56            index_memory_budget_mb: 50,
57        }
58    }
59}
60
61impl WarmupConfig {
62    /// Check if flat warmup should be performed
63    pub fn should_warmup_flats(&self) -> bool {
64        self.warmup_enabled
65    }
66
67    /// Check if mask warmup should be performed
68    pub fn should_warmup_masks(&self) -> bool {
69        self.warmup_enabled
70    }
71
72    /// Check if index warmup should be performed
73    pub fn should_warmup_indexes(&self) -> bool {
74        self.warmup_enabled
75    }
76}