iris: on-demand message-list/image benchmarks, and two O(N) findings
IRIS_TODO.md's "Benchmarks" item: a message list of N wrapped-text rows (first-frame cost), scrolling it, and growing an input box above which the list must move rather than re-layout -- all as a plain, harness=false `cargo bench` binary (iris/benches/message_list.rs) since UiRenderState touches no GPU or window, chosen over criterion because every scenario here reduces to a count take_counters already answers exactly, and a new dependency wasn't worth it. Scroll (200 ticks) and the input-grow case (40 lines) are flat across N=100/1,000/10,000: LAYOUT.md's O(1) move chain holds. The many-images case (d) needs a real wgpu device, so it's a headless example (iris/examples/bench_images.rs) plus a new GpuTextures/UiRenderNode counter, take_image_bind_group_creates, mirroring take_counters. It found two real non-O(1) costs, recorded as new Fix items rather than redesigned: bind-group creation takes two frames to settle after a cold load instead of one, and appending a single image to an already-loaded 1,000-image list rebuilds all 1,000 existing bind groups (masks/move_offsets buffer growth triggers rebuild_image_bind_groups unconditionally). run-bench.sh wraps both. Numbers and commands are in IRIS_TODO.md. cargo fmt --all -- --check, cargo clippy --all-targets, and cargo test --workspace (19 passed) all clean; benches are not run by cargo test. Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
1 parent
fba572427d
commit
288853c094
7 files changed
+531
-11
No files matched your search
@@ -441,4 +441,11 @@ impl UiRenderNode {
|
||||
pub fn view_count(&self) -> usize {
|
||||
self.textures.view_count()
|
||||
}
|
||||
|
||||
/// Standalone-image bind groups built since the last call -- see
|
||||
/// `GpuTextures::take_bind_group_creates`. Call once per frame before
|
||||
/// `update()` to measure exactly that frame.
|
||||
pub fn take_image_bind_group_creates(&mut self) -> u64 {
|
||||
self.textures.take_bind_group_creates()
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,14 @@ pub struct GpuTextures {
|
||||
/// nothing of its own to put there: rects and glyphs never sample it,
|
||||
/// but the layout requires something bound regardless.
|
||||
null_view: TextureView,
|
||||
|
||||
/// Standalone-image bind groups actually built (`create_image`'s own
|
||||
/// build, or one per slot touched by `rebuild_image_bind_groups`) since
|
||||
/// the last `take_bind_group_creates`. IRIS_TODO.md's "many images"
|
||||
/// benchmark reads this to prove the steady-state cost of an
|
||||
/// unchanging image list is zero, the same way `UiRenderState`'s
|
||||
/// `draw_count`/`region_mut_count` prove the layout side.
|
||||
bind_group_creates: u64,
|
||||
}
|
||||
|
||||
impl GpuTextures {
|
||||
@@ -297,12 +305,13 @@ impl GpuTextures {
|
||||
masks,
|
||||
move_offsets,
|
||||
);
|
||||
self.bind_group_creates += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_image(
|
||||
&self,
|
||||
&mut self,
|
||||
image: &DynamicImage,
|
||||
rsc_layout: &BindGroupLayout,
|
||||
masks: &ArrBuf<Mask>,
|
||||
@@ -339,6 +348,7 @@ impl GpuTextures {
|
||||
masks,
|
||||
move_offsets,
|
||||
);
|
||||
self.bind_group_creates += 1;
|
||||
ImageGpu {
|
||||
texture,
|
||||
view,
|
||||
@@ -424,9 +434,17 @@ impl GpuTextures {
|
||||
page_count: 0,
|
||||
sampler,
|
||||
null_view,
|
||||
bind_group_creates: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads and zeroes the standalone-image bind-group creation counter --
|
||||
/// call once per frame before `update()`, mirroring
|
||||
/// `UiRenderState::take_counters`.
|
||||
pub fn take_bind_group_creates(&mut self) -> u64 {
|
||||
std::mem::take(&mut self.bind_group_creates)
|
||||
}
|
||||
|
||||
pub fn array_view(&self) -> &TextureView {
|
||||
&self.array_view
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user