Report factor value bytes and preserve overflow-safe reduction limits

This commit is contained in:
Preetinder Kalsi authored and Irakli Kourtis committed 2026-10-15 14:00:56 -04:00
1 parent c7d0a82079
commit a530a0d914
7 files changed
+80 -12

No files matched your search

+16 -1
View File
@@ -367,7 +367,7 @@ impl Budget {
}
fn exceeded(&self, entries: usize) -> bool {
self.bytes(entries) > self.max_bytes
entries > self.max_bytes / (8 * (1 + self.matrices))
}
}
@@ -770,3 +770,18 @@ impl Reduction {
out
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn reduced_matrix_budget_refuses_byte_counts_that_overflow() {
for matrices in [1, 2] {
let budget = Budget { max_bytes: usize::MAX, pattern_entries: 0, matrices };
let entries = usize::MAX / (8 * (1 + matrices));
assert!(!budget.exceeded(entries));
assert!(budget.exceeded(entries + 1));
}
}
}