From 257f0a0d313aa4b3f8b9de017817926d0225680d Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Fri, 16 Oct 2026 17:34:59 -0400 Subject: [PATCH 1/5] GPU canvas: a layer that doesn't fit GPU memory evicts and retries instead of breaking the GPU (#6563) Compositor::sync created each pc_compose_layer page texture with a bare create_texture: nothing checked the new bytes against the resident budget (eviction ran only after each cell) and an Out of Memory error went uncaptured, invalidating every later texture in the pass. Now least recently used pages are evicted to admit the new page's bytes before creating it; creation runs in error scopes (first_error) on native, and on Out of Memory every page the current cell doesn't use is dropped and creation is retried once. If it still fails the refresh returns Unsupported(OVER_BUDGET) so that refresh draws on the CPU and the next one tries the GPU again; the captured error no longer reaches the health callbacks. The LRU admission logic is a pure function with a unit test. Co-Authored-By: Claude Opus 5.5 --- crates/gpu/src/lib.rs | 122 ++++++++++++++++++++++++++----- crates/ui-egui/src/gpu_canvas.rs | 5 +- 2 files changed, 106 insertions(+), 21 deletions(-) diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index 690d144d68a..a7699d8dd35 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -461,6 +461,8 @@ pub struct Compositor { staged: u64, /// Copies and render passes recorded since the last submit. recorded: u32, + /// Why a layer page texture couldn't be created this refresh (it then ends on the CPU). + layer_alloc: Option, acc_format: wgpu::TextureFormat, /// Whether the effect-map pipelines could be built (else documents with layer effects are /// [`Unsupported`] and use the CPU compositor). @@ -569,6 +571,25 @@ fn field_reaches(progs: &[fx::MapProgram]) -> HashMap { want } +/// Why a refresh whose layer pages don't fit GPU memory is drawn on the CPU. +pub const OVER_BUDGET: &str = "layers exceed the GPU memory budget; full refresh on the CPU"; + +/// Which of `pages` (LRU clock, key, bytes) to drop, least recently used first, so `incoming` +/// more bytes fit `budget` on top of the `total` held now. Callers leave out pages that must stay. +fn lru_victims(mut pages: Vec<(u64, K, u64)>, total: u64, incoming: u64, budget: u64) -> Vec { + pages.sort_unstable_by_key(|p| p.0); + let mut total = total; + let mut out = Vec::new(); + for (_, k, bytes) in pages { + if total.saturating_add(incoming) <= budget { + break; + } + total = total.saturating_sub(bytes); + out.push(k); + } + out +} + /// Runs `f` inside GPU error scopes and returns the first error raised. /// Native wgpu reports errors synchronously; where they only arrive asynchronously (WebGPU) none /// is reported. @@ -700,6 +721,7 @@ impl Compositor { stamp: 0, staged: 0, recorded: 0, + layer_alloc: None, acc_format, effect_maps: map_error.is_none(), cmyk: 0, @@ -1067,6 +1089,7 @@ impl Compositor { self.stamp += 1; self.staged = 0; self.recorded = 0; + self.layer_alloc = None; // Only render owns submission. A caller may discard encode's command buffer, so it // cannot establish (or consume) a checkpoint whose GPU copy might never execute. @@ -1120,6 +1143,11 @@ impl Compositor { if let Some(f) = self.fault() { return Err(Unsupported(f.to_string())); } + // A page didn't fit even after evicting: this refresh goes to the CPU, the next one + // tries the GPU again (#6563). + if let Some(e) = self.layer_alloc.take() { + return Err(Unsupported(e)); + } let (evicted, bytes) = self.evict(); stats.evicted += evicted; freed += bytes; @@ -1175,22 +1203,7 @@ impl Compositor { /// whole-region effect maps drawn this frame. Returns how many textures were dropped and /// their bytes. fn evict(&mut self) -> (usize, u64) { - let (mut n, mut freed) = (0, 0u64); - let mut total = self.resident_bytes(); - if total > self.resident_budget { - let mut lru: Vec<(u64, ResKey, u64)> = - self.residents.iter().filter(|(_, r)| r.stamp != self.stamp).map(|(k, r)| (r.stamp, *k, r.bytes())).collect(); - lru.sort_unstable_by_key(|c| c.0); - for (_, k, bytes) in lru { - if total <= self.resident_budget { - break; - } - self.residents.remove(&k); - total = total.saturating_sub(bytes); - n += 1; - freed += bytes; - } - } + let (mut n, mut freed) = self.evict_residents(self.resident_budget, 0, None); let mut total = self.fx_cache_bytes(); let fx_budget = usize::try_from(self.fx_budget).unwrap_or(usize::MAX); if total > fx_budget { @@ -1216,6 +1229,55 @@ impl Compositor { (n, freed) } + /// Drop least recently used resident pages until `incoming` more bytes fit in `budget`. + /// Never drops what the current cell uses, nor `keep`. Returns how many pages were dropped + /// and their bytes. + fn evict_residents(&mut self, budget: u64, incoming: u64, keep: Option) -> (usize, u64) { + let stamp = self.stamp; + let pages: Vec<(u64, ResKey, u64)> = + self.residents.iter().filter(|(k, r)| r.stamp != stamp && Some(**k) != keep).map(|(k, r)| (r.stamp, *k, r.bytes())).collect(); + let (mut n, mut freed) = (0, 0u64); + for k in lru_victims(pages, self.resident_bytes(), incoming, budget) { + if let Some(r) = self.residents.remove(&k) { + n += 1; + freed += r.bytes(); + } + } + (n, freed) + } + + /// Create the page texture for `key`, `bytes` large. Least recently used pages make room in + /// the budget first; when the device is still out of memory, every page the current cell + /// doesn't use is dropped and creation is tried once more (#6563). `None` (with + /// `layer_alloc` set) when it still fails: the refresh ends and the CPU draws it. + fn create_layer_texture(&mut self, device: &wgpu::Device, desc: &wgpu::TextureDescriptor<'_>, key: ResKey, bytes: u64) -> Option { + let replaced = self.residents.get(&key).map_or(0, Resident::bytes); + self.evict_residents(self.resident_budget, bytes.saturating_sub(replaced), Some(key)); + // WebGPU reports errors asynchronously: its failures reach the health callbacks. + if cfg!(target_arch = "wasm32") { + return Some(device.create_texture(desc)); + } + for retry in [false, true] { + let (texture, error) = first_error(device, || device.create_texture(desc)); + match error { + None => return Some(texture), + Some(wgpu::Error::OutOfMemory { .. }) if !retry => { + self.evict_residents(0, 0, Some(key)); + } + Some(wgpu::Error::OutOfMemory { .. }) => { + self.layer_alloc = Some(OVER_BUDGET.into()); + return None; + } + Some(e) => { + self.layer_alloc = Some(format!("GPU layer texture failed: {e}")); + return None; + } + } + } + self.layer_alloc = Some(OVER_BUDGET.into()); + None + } + /// Per-frame resources of `plan`: the tile area of each pass's surfaces, its LUT and pattern. fn frame_res(&mut self, device: &wgpu::Device, queue: &wgpu::Queue, canvas: Rect, plan: &Plan<'_>) -> FrameRes { let grid = tile_grid(canvas); @@ -1314,6 +1376,10 @@ impl Compositor { .and_then(|_| chunks.iter().map(|c| self.prefix.restore_point(*c).map(|r| r.pass_end)).try_fold(usize::MAX, |m, p| Some(m.min(p?)))) .unwrap_or(0); let bound = self.bind_cell(device, queue, encoder, doc, plan, paged, cell, fr, first_pass, stats); + // A page couldn't be created: draw nothing with the pages missing (the caller ends the refresh). + if self.layer_alloc.is_some() { + return; + } // Chunk pool. while self.pool.len() < plan.slots as usize { @@ -1503,7 +1569,8 @@ impl Compositor { region: Rect, stats: &mut Stats, ) -> Option<(ResKey, [i32; 4])> { - if region.is_empty() { + // An earlier page of this cell didn't fit: the refresh ends after the cell anyway. + if region.is_empty() || self.layer_alloc.is_some() { return None; } let format = surface.format(); @@ -1516,7 +1583,7 @@ impl Compositor { .get(&key) .is_none_or(|r| r.region != region || r.kind != kind || r.format != format || r.cmyk != cmyk || r.default_bits != default_bits); if stale { - let texture = device.create_texture(&wgpu::TextureDescriptor { + let desc = wgpu::TextureDescriptor { label: Some("pc_compose_layer"), size: wgpu::Extent3d { width: region.width(), height: region.height(), depth_or_array_layers: 1 }, mip_level_count: 1, @@ -1525,7 +1592,9 @@ impl Compositor { format: kind.format(), usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::COPY_SRC, view_formats: &[], - }); + }; + let bytes = region.width() as u64 * region.height() as u64 * kind.bytes_per_pixel() as u64; + let texture = self.create_layer_texture(device, &desc, key, bytes)?; let view = texture.create_view(&Default::default()); let default_nonzero = default_pixel.iter().any(|v| *v != 0.0); let mut r = Resident { @@ -2440,6 +2509,21 @@ pub fn render_to_vec_stats( mod tests { use super::*; + #[test] + fn layer_pages_are_admitted_by_evicting_least_recently_used_first() { + let pages = || vec![(5, 'c', 40), (1, 'a', 30), (3, 'b', 20)]; + // Fits already: nothing dropped. + assert!(lru_victims(pages(), 90, 10, 100).is_empty()); + // 90 held + 40 incoming over 100: the oldest page goes first, then the next. + assert_eq!(lru_victims(pages(), 90, 40, 100), vec!['a']); + assert_eq!(lru_victims(pages(), 90, 60, 100), vec!['a', 'b']); + // Out of memory: a zero budget drops every candidate, and an impossible request stops + // when none are left instead of looping or overflowing. + assert_eq!(lru_victims(pages(), 90, 0, 0), vec!['a', 'b', 'c']); + assert_eq!(lru_victims(pages(), u64::MAX, u64::MAX, 1), vec!['a', 'b', 'c']); + assert!(lru_victims(Vec::<(u64, char, u64)>::new(), 90, 40, 100).is_empty()); + } + #[test] fn uniform_buffer_sizes_are_checked_before_allocation() { assert_eq!(uniform_buffer_len(1, 255, 65_536).unwrap(), 65_536); diff --git a/crates/ui-egui/src/gpu_canvas.rs b/crates/ui-egui/src/gpu_canvas.rs index 012bcf801cb..2f21b4b9cbe 100644 --- a/crates/ui-egui/src/gpu_canvas.rs +++ b/crates/ui-egui/src/gpu_canvas.rs @@ -1261,8 +1261,9 @@ impl LayerFit { /// Floor of the compositor's memory budget: enough for a viewport's pages of a dozen layers. pub const MIN_GPU_BUDGET: u64 = 512 << 20; -/// Why a full refresh whose layer pages don't fit [`memory_budget`] goes to the CPU compositor. -pub const OVER_BUDGET: &str = "layers exceed the GPU memory budget; full refresh on the CPU"; +/// Why a full refresh whose layer pages don't fit [`memory_budget`] (or GPU memory) goes to the +/// CPU compositor. +pub const OVER_BUDGET: &str = photocraft_gpu::OVER_BUDGET; /// GPU memory the wgpu compositor may hold for layer pages and effect maps. /// From 3e373ddef8524953793d57bd088b2f35db32e67e Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Fri, 16 Oct 2026 19:43:00 -0400 Subject: [PATCH 2/5] GPU canvas: count pages evicted to admit a layer texture in render stats (#6563) Admission now evicts before creating a page, so the post-cell evict found nothing over budget and Stats::evicted stayed 0 (pages_are_evicted_under_the_budget). Co-Authored-By: Claude Opus 5.5 --- crates/gpu/src/lib.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index a7699d8dd35..ff069ad1ed0 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -1250,9 +1250,16 @@ impl Compositor { /// the budget first; when the device is still out of memory, every page the current cell /// doesn't use is dropped and creation is tried once more (#6563). `None` (with /// `layer_alloc` set) when it still fails: the refresh ends and the CPU draws it. - fn create_layer_texture(&mut self, device: &wgpu::Device, desc: &wgpu::TextureDescriptor<'_>, key: ResKey, bytes: u64) -> Option { + fn create_layer_texture( + &mut self, + device: &wgpu::Device, + desc: &wgpu::TextureDescriptor<'_>, + key: ResKey, + bytes: u64, + stats: &mut Stats, + ) -> Option { let replaced = self.residents.get(&key).map_or(0, Resident::bytes); - self.evict_residents(self.resident_budget, bytes.saturating_sub(replaced), Some(key)); + stats.evicted += self.evict_residents(self.resident_budget, bytes.saturating_sub(replaced), Some(key)).0; // WebGPU reports errors asynchronously: its failures reach the health callbacks. if cfg!(target_arch = "wasm32") { return Some(device.create_texture(desc)); @@ -1262,7 +1269,7 @@ impl Compositor { match error { None => return Some(texture), Some(wgpu::Error::OutOfMemory { .. }) if !retry => { - self.evict_residents(0, 0, Some(key)); + stats.evicted += self.evict_residents(0, 0, Some(key)).0; } Some(wgpu::Error::OutOfMemory { .. }) => { self.layer_alloc = Some(OVER_BUDGET.into()); @@ -1594,7 +1601,7 @@ impl Compositor { view_formats: &[], }; let bytes = region.width() as u64 * region.height() as u64 * kind.bytes_per_pixel() as u64; - let texture = self.create_layer_texture(device, &desc, key, bytes)?; + let texture = self.create_layer_texture(device, &desc, key, bytes, stats)?; let view = texture.create_view(&Default::default()); let default_nonzero = default_pixel.iter().any(|v| *v != 0.0); let mut r = Resident { From 3d53024a999cb7f1bbd82276e32d8bd2f945ebb3 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Sat, 17 Oct 2026 11:16:45 -0400 Subject: [PATCH 3/5] GPU canvas: test layer-page admission under a zero budget (#6563) A paged render with a zero resident budget evicts the previous cell's pages as each new page is created, stays on the GPU and matches the CPU compositor. Co-Authored-By: Claude Opus 5.5 --- crates/gpu/tests/parity.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/gpu/tests/parity.rs b/crates/gpu/tests/parity.rs index 84d3d0e9370..02184f286f2 100644 --- a/crates/gpu/tests/parity.rs +++ b/crates/gpu/tests/parity.rs @@ -2571,6 +2571,38 @@ fn pages_are_evicted_under_the_budget() { check(&mut g, &d, "after eviction"); } +/// #6563: a page texture that doesn't fit the budget is admitted by first dropping the least +/// recently used pages of other cells (never the current cell's). With a zero budget every page +/// created in a cell evicts the previous cell's pages, and the refresh still stays on the GPU +/// (budget pressure alone never ends it on the CPU) and matches the CPU compositor. +#[test] +fn layer_pages_are_admitted_under_a_zero_budget_and_stay_on_the_gpu() { + let Some(mut g) = gpu() else { return }; + let mut d = base_doc(600, 500); + d.layers.push(noise_layer("mid", PixelFormat::RGBA8, Rect::new(-20, 10, 590, 480), 61, 0.0)); + let mut top = noise_layer("top", PixelFormat::RGBA8, Rect::new(30, -15, 620, 510), 62, 0.2); + top.blend = BlendMode::Multiply; + d.layers.push(top); + // Exercise page residency itself: lower-stack checkpoints could skip binding the pages. + g.paged.set_composite_cache_budget(0); + check(&mut g, &d, "warm"); + let all = g.paged.resident_bytes(); + g.paged.set_resident_budget(0); + for round in 0..2 { + let cpu = photocraft_compose::flatten(&d); + let (out, s) = photocraft_gpu::render_to_vec_stats(&mut g.paged, &g.device, &g.queue, &d, d.bounds()) + .unwrap_or_else(|e| panic!("round {round}: a zero budget must not end the refresh on the CPU: {e}")); + let worst = worst_diff(&cpu.px, &out); + assert!(worst.0 <= TOL, "round {round}: max diff {:.2}/255 at {}", worst.0 * 255.0, worst.1); + assert!(s.cells > 1 && s.evicted > 0, "round {round}: {s:?}"); + // Evicted pages were created again (uploaded), and only the last cell's are left. + assert!(s.tiles_uploaded > 0, "round {round}: {s:?}"); + assert!(g.paged.resident_bytes() < all, "round {round}: {} of {all}", g.paged.resident_bytes()); + d.layers[1].surface_mut().unwrap().fill_rect(Rect::new(40 + round * 250, 60, 90 + round * 250, 120), &[0.2, 0.8, 0.3, 1.0]); + } + check(&mut g, &d, "after zero-budget renders"); +} + #[test] fn the_focused_view_stays_resident_after_a_full_refresh() { let _gamma = TEXT_GAMMA.lock().unwrap_or_else(|e| e.into_inner()); From 1b84acd2e3f4f75f2ab7bd77eb07f23ad6dcd087 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 20:52:51 -0400 Subject: [PATCH 4/5] GPU compositor: on a layer page OOM, submit and wait before the last retry Pages dropped to make room can still be held by the work recorded since the last submit, so the immediate retry may fail although the memory is about to be freed. render now submits, waits for the GPU and runs the cell once more before sending the refresh to the CPU (encode, which can't submit, still goes to the CPU). Bytes dropped to admit pages also count towards the intermediate-submit threshold. Co-Authored-By: Claude Opus 5.5 --- crates/gpu/src/lib.rs | 48 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index 30689a97d6c..b982c273116 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -468,6 +468,8 @@ pub struct Compositor { recorded: u32, /// Why a layer page texture couldn't be created this refresh (it then ends on the CPU). layer_alloc: Option, + /// Bytes of pages dropped to admit new ones, not yet counted towards an intermediate submit. + admit_freed: u64, acc_format: wgpu::TextureFormat, /// Whether the effect-map pipelines could be built (else documents with layer effects are /// [`Unsupported`] and use the CPU compositor). @@ -727,6 +729,7 @@ impl Compositor { staged: 0, recorded: 0, layer_alloc: None, + admit_freed: 0, acc_format, effect_maps: map_error.is_none(), cmyk: 0, @@ -1095,6 +1098,7 @@ impl Compositor { self.staged = 0; self.recorded = 0; self.layer_alloc = None; + self.admit_freed = 0; // Only render owns submission. A caller may discard encode's command buffer, so it // cannot establish (or consume) a checkpoint whose GPU copy might never execute. @@ -1148,6 +1152,37 @@ impl Compositor { if let Some(f) = self.fault() { return Err(Unsupported(f.to_string())); } + // Out of memory although every page this cell doesn't use was dropped: the work recorded + // since the last submit can still hold those pages. Submit it, wait until the GPU is done + // with it so their memory is released, and run the cell once more. `encode` can't + // submit, so there the refresh goes to the CPU straight away. + if flush && self.layer_alloc.as_deref() == Some(OVER_BUDGET) { + self.layer_alloc = None; + submit_batch(device, queue, encoder, self.health.as_ref(), &mut last_submit); + #[cfg(not(target_arch = "wasm32"))] + match self.health.as_ref() { + Some(h) => { + h.wait(device, last_submit.clone()); + } + None => { + let _ = device.poll(wgpu::PollType::Wait { submission_index: last_submit.clone(), timeout: None }); + } + } + self.staged = 0; + self.recorded = 0; + work = 0; + freed = 0; + self.admit_freed = 0; + stats.flushes += 1; + if let Some(f) = self.fault() { + return Err(Unsupported(f.to_string())); + } + let mut batch = Some(&mut last_submit); + self.run_cell(device, queue, encoder, doc.id, &plan, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch); + if let Some(f) = self.fault() { + return Err(Unsupported(f.to_string())); + } + } // A page didn't fit even after evicting: this refresh goes to the CPU, the next one // tries the GPU again (#6563). if let Some(e) = self.layer_alloc.take() { @@ -1155,7 +1190,7 @@ impl Compositor { } let (evicted, bytes) = self.evict(); stats.evicted += evicted; - freed += bytes; + freed += bytes + std::mem::take(&mut self.admit_freed); if flush && (self.staged >= flush_bytes || work >= FLUSH_WORK || freed >= flush_bytes || self.recorded >= FLUSH_OPS) { submit_batch(device, queue, encoder, self.health.as_ref(), &mut last_submit); self.staged = 0; @@ -1254,7 +1289,8 @@ impl Compositor { /// Create the page texture for `key`, `bytes` large. Least recently used pages make room in /// the budget first; when the device is still out of memory, every page the current cell /// doesn't use is dropped and creation is tried once more (#6563). `None` (with - /// `layer_alloc` set) when it still fails: the refresh ends and the CPU draws it. + /// `layer_alloc` set) when it still fails: `render` submits the recorded work, which can still + /// hold the dropped pages, and runs the cell once more; after that the CPU draws the refresh. fn create_layer_texture( &mut self, device: &wgpu::Device, @@ -1264,7 +1300,9 @@ impl Compositor { stats: &mut Stats, ) -> Option { let replaced = self.residents.get(&key).map_or(0, Resident::bytes); - stats.evicted += self.evict_residents(self.resident_budget, bytes.saturating_sub(replaced), Some(key)).0; + let (n, dropped) = self.evict_residents(self.resident_budget, bytes.saturating_sub(replaced), Some(key)); + stats.evicted += n; + self.admit_freed = self.admit_freed.saturating_add(dropped); // WebGPU reports errors asynchronously: its failures reach the health callbacks. if cfg!(target_arch = "wasm32") { return Some(device.create_texture(desc)); @@ -1274,7 +1312,9 @@ impl Compositor { match error { None => return Some(texture), Some(wgpu::Error::OutOfMemory { .. }) if !retry => { - stats.evicted += self.evict_residents(0, 0, Some(key)).0; + let (n, dropped) = self.evict_residents(0, 0, Some(key)); + stats.evicted += n; + self.admit_freed = self.admit_freed.saturating_add(dropped); } Some(wgpu::Error::OutOfMemory { .. }) => { self.layer_alloc = Some(OVER_BUDGET.into()); From ac1a7443a95c62f175d189a0674412492d54a5b4 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 21:09:52 -0400 Subject: [PATCH 5/5] GPU compositor: pass the timer and batch runs in the OOM retry (main changed submit_batch and run_cell) main added a GPU timer argument to submit_batch and the batch runs to run_cell, so the OOM submit-and-retry path no longer compiled after the merge. Also add the admission-evicted bytes to the flush counter with saturating arithmetic. Co-Authored-By: Claude Opus 5.5 --- crates/gpu/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index e9f0262d5f8..7b5c732c235 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -1258,7 +1258,7 @@ impl Compositor { // submit, so there the refresh goes to the CPU straight away. if flush && self.layer_alloc.as_deref() == Some(OVER_BUDGET) { self.layer_alloc = None; - submit_batch(device, queue, encoder, self.health.as_ref(), &mut last_submit); + submit_batch(device, queue, encoder, self.health.as_ref(), self.timer.as_mut(), &mut last_submit); #[cfg(not(target_arch = "wasm32"))] match self.health.as_ref() { Some(h) => { @@ -1278,7 +1278,7 @@ impl Compositor { return Err(Unsupported(f.to_string())); } let mut batch = Some(&mut last_submit); - self.run_cell(device, queue, encoder, doc.id, &plan, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch); + self.run_cell(device, queue, encoder, doc.id, &plan, &runs, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch); if let Some(f) = self.fault() { return Err(Unsupported(f.to_string())); } @@ -1290,7 +1290,7 @@ impl Compositor { } let (evicted, bytes) = self.evict(); stats.evicted += evicted; - freed += bytes + std::mem::take(&mut self.admit_freed); + freed = freed.saturating_add(bytes.saturating_add(std::mem::take(&mut self.admit_freed))); if flush && (self.staged >= flush_bytes || work >= FLUSH_WORK || freed >= flush_bytes || self.recorded >= FLUSH_OPS) { submit_batch(device, queue, encoder, self.health.as_ref(), self.timer.as_mut(), &mut last_submit); self.staged = 0;