diff --git a/CLAUDE.md b/CLAUDE.md index f25d1bd..0787f96 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,6 +5,7 @@ The app must stay as fluid and light as possible: it never feels slow and never - Any change that touches rendering, background work or memory measures before and after with the probes, on a release build (`scripts/prod`) on the reference machine, and records the numbers on its ticket. Debug numbers never count. - A change that exceeds a budget is not done. When a budget is beaten durably, lower it in `docs/performance.md` (ratchet); never raise it. - Do not modify GPUI or gpui-component to meet a budget: reduce the app's own rendering cost (ADR-0004). +- A part of the page gets its own view for a reason: it owns state that changes on its own (the champion table: sort, selection, scroll, hover), or it is a cached view with a measured gain and a structural test (`docs/performance.md`). Other parts render as functions in their parent's render. ## Agent skills diff --git a/Cargo.lock b/Cargo.lock index aa1f8fa..96024a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,6 +149,15 @@ dependencies = [ "equator", ] +[[package]] +name = "alloca" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7d05ea6aea7e9e64d25b9156ba2fee3fdd659e34e41063cd2fc7cd020d7f4" +dependencies = [ + "cc", +] + [[package]] name = "allocator-api2" version = "0.2.21" @@ -164,6 +173,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "annotate-snippets" version = "0.12.18" @@ -209,6 +224,7 @@ dependencies = [ "arena-tracker-core", "embed-resource", "gpui-kit", + "gpui-pre", ] [[package]] @@ -450,6 +466,12 @@ dependencies = [ "syn 3.0.10", ] +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + [[package]] name = "atomic-waker" version = "1.1.2" @@ -581,7 +603,16 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" dependencies = [ - "bit-vec", + "bit-vec 0.9.1", +] + +[[package]] +name = "bit-set" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d87354e4229f54a44f7bf2435906a4656dba36026ab6eaca629a2c436a691c" +dependencies = [ + "bit-vec 0.10.2", ] [[package]] @@ -590,6 +621,16 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" +[[package]] +name = "bit-vec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72503af1e72be411d74ca45cd6b309878fcb35354e252fc2a3a8bda3a97082a0" +dependencies = [ + "borsh", + "serde", +] + [[package]] name = "bit_field" version = "0.10.4" @@ -681,6 +722,30 @@ dependencies = [ "piper", ] +[[package]] +name = "borsh" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" +dependencies = [ + "borsh-derive", + "bytes", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "bstr" version = "1.13.1" @@ -742,6 +807,12 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "c-enum" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd17eb909a8c6a894926bfcc3400a4bb0e732f5a57d37b1f14e8b29e329bace8" + [[package]] name = "calloop" version = "0.14.5" @@ -766,6 +837,12 @@ dependencies = [ "wayland-client", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cbc" version = "0.1.2" @@ -842,6 +919,33 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cipher" version = "0.4.4" @@ -853,6 +957,31 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clap" +version = "4.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac230478587d0269d8d6998b82ae69ea51509d55df66d9e92edd1f986904cd4a" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79" + [[package]] name = "cocoa" version = "0.25.0" @@ -954,6 +1083,15 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "convert_case" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -1119,6 +1257,41 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "950046b2aa2492f9a536f5f4f9a3de7b9e2476e575e05bd6c333371add4d98f3" +dependencies = [ + "alloca", + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools 0.13.0", + "num-traits", + "oorandom", + "page_size", + "plotters", + "rayon", + "regex", + "serde", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8d80a2f4f5b554395e47b5d8305bc3d27813bacb73493eb1001e8f76dae29ea" +dependencies = [ + "cast", + "itertools 0.13.0", +] + [[package]] name = "crossbeam-deque" version = "0.8.8" @@ -1138,6 +1311,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.23" @@ -1212,7 +1394,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" dependencies = [ - "convert_case", + "convert_case 0.10.0", "proc-macro2", "quote", "rustc_version", @@ -1601,6 +1783,12 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" +[[package]] +name = "fixedbitset" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175" + [[package]] name = "flate2" version = "1.1.11" @@ -1785,6 +1973,19 @@ dependencies = [ "futures-sink", ] +[[package]] +name = "futures-concurrency" +version = "7.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175cd8cca9e1d45b87f18ffa75088f2099e3c4fe5e2f83e42de112560bea8ea6" +dependencies = [ + "fixedbitset", + "futures-core", + "futures-lite", + "pin-project", + "smallvec", +] + [[package]] name = "futures-core" version = "0.3.34" @@ -2165,7 +2366,7 @@ dependencies = [ "parking", "parking_lot", "pin-project", - "pollster", + "pollster 0.4.0", "profiling", "rand 0.9.5", "raw-window-handle", @@ -2251,7 +2452,9 @@ dependencies = [ "embed-resource", "etagere", "futures", + "futures-concurrency", "getrandom 0.3.4", + "gpui-pre-bench-metrics", "gpui-pre-collections", "gpui-pre-http-client", "gpui-pre-macros", @@ -2275,8 +2478,10 @@ dependencies = [ "parking", "parking_lot", "pin-project", - "pollster", + "pollster 0.4.0", + "postage", "profiling", + "proptest", "rand 0.9.5", "raw-window-handle", "regex", @@ -2297,6 +2502,7 @@ dependencies = [ "usvg 0.46.0", "uuid", "waker-fn", + "web-time", "windows 0.62.2", "zed-scap", ] @@ -2341,6 +2547,18 @@ dependencies = [ "zed-font-kit", ] +[[package]] +name = "gpui-pre-bench-metrics" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6a8ff719fdc3da4f5f497b5d39c5545634424073f94943b003c818fc95e1d5" +dependencies = [ + "anyhow", + "criterion", + "libc", + "perf-event2", +] + [[package]] name = "gpui-pre-collections" version = "0.3.12" @@ -2374,6 +2592,7 @@ dependencies = [ "futures", "http", "http-body", + "log", "parking_lot", "serde", "serde_json", @@ -3231,7 +3450,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" dependencies = [ "byteorder-lite", - "quick-error", + "quick-error 2.0.1", ] [[package]] @@ -3899,7 +4118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd0dd362bf26c0ffdd143df6da66a25d287e196eff482f117771010b207ad163" dependencies = [ "arrayvec", - "bit-set", + "bit-set 0.10.0", "bitflags 2.13.2", "cfg-if", "cfg_aliases", @@ -4561,6 +4780,12 @@ dependencies = [ "zvariant", ] +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + [[package]] name = "open" version = "5.4.5" @@ -4602,6 +4827,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "page_size" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "parking" version = "2.2.1" @@ -4678,6 +4913,41 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "perf-event-data" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575828d9d7d205188048eb1508560607a03d21eafdbba47b8cade1736c1c28e1" +dependencies = [ + "bitflags 2.13.2", + "c-enum", + "perf-event-open-sys2", +] + +[[package]] +name = "perf-event-open-sys2" +version = "5.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c25955321465255e437600b54296983fab1feac2cd0c38958adeb26dbae49e" +dependencies = [ + "libc", + "memoffset", +] + +[[package]] +name = "perf-event2" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0939b8fad77dfaeb29ebbd35faaeaadbf833167f30975f1b8993bbba09ea0a0f" +dependencies = [ + "bitflags 2.13.2", + "c-enum", + "libc", + "memmap2", + "perf-event-data", + "perf-event-open-sys2", +] + [[package]] name = "phf" version = "0.11.3" @@ -4808,6 +5078,34 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] + [[package]] name = "png" version = "0.17.16" @@ -4848,6 +5146,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "pollster" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da3b0203fd7ee5720aa0b5e790b591aa5d3f41c3ed2c34a3a393382198af2f7" + [[package]] name = "pollster" version = "0.4.0" @@ -4878,6 +5182,21 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "postage" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3fb618632874fb76937c2361a7f22afd393c982a2165595407edc75b06d3c1" +dependencies = [ + "atomic", + "crossbeam-queue", + "parking_lot", + "pin-project", + "pollster 0.2.5", + "static_assertions", + "thiserror 1.0.69", +] + [[package]] name = "potential_utf" version = "0.1.6" @@ -4953,6 +5272,39 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "proptest" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8530004ccb15eae51c7e40009fbe317f341f804db54dc033eec1c50be28cfa0" +dependencies = [ + "bit-set 0.11.1", + "bit-vec 0.10.2", + "bitflags 2.13.2", + "chacha20", + "core_detect", + "num-traits", + "proptest-macro", + "rand 0.10.4", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "proptest-macro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e99782ea31698c2206c6887c1220d2f594b291c26cb9ec5b6d7cf175320bc212" +dependencies = [ + "convert_case 0.11.0", + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "pxfm" version = "0.1.30" @@ -4968,6 +5320,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-error" version = "2.0.1" @@ -5145,6 +5503,15 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "rand_xorshift" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60aa6af80be32871323012e02e6e65f8a7cc7890931ae421d217ad8fe0df2ccf" +dependencies = [ + "rand_core 0.10.1", +] + [[package]] name = "range-alloc" version = "0.1.5" @@ -5201,7 +5568,7 @@ dependencies = [ "avif-serialize", "imgref", "loop9", - "quick-error", + "quick-error 2.0.1", "rav1e", "rayon", "rgb", @@ -5645,6 +6012,18 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" +[[package]] +name = "rusty-fork" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2" +dependencies = [ + "fnv", + "quick-error 1.2.3", + "tempfile", + "wait-timeout", +] + [[package]] name = "rustybuzz" version = "0.20.1" @@ -6465,7 +6844,7 @@ dependencies = [ "fax", "flate2", "half", - "quick-error", + "quick-error 2.0.1", "weezl", "zune-jpeg 0.5.15", ] @@ -6535,6 +6914,16 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.13.3" @@ -6804,6 +7193,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicase" version = "2.10.0" @@ -7060,6 +7455,15 @@ dependencies = [ "libc", ] +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + [[package]] name = "waker-fn" version = "1.2.0" @@ -7360,8 +7764,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad661da2ee99f208c30090b585284b2ab5b8bf2358ddf2d2215592808ec62f1a" dependencies = [ "arrayvec", - "bit-set", - "bit-vec", + "bit-set 0.10.0", + "bit-vec 0.9.1", "bitflags 2.13.2", "bytemuck", "cfg_aliases", @@ -7433,7 +7837,7 @@ dependencies = [ "android_system_properties", "arrayvec", "ash", - "bit-set", + "bit-set 0.10.0", "bitflags 2.13.2", "block2 0.6.2", "bytemuck", diff --git a/crates/app/Cargo.toml b/crates/app/Cargo.toml index c535a8c..e6e583b 100644 --- a/crates/app/Cargo.toml +++ b/crates/app/Cargo.toml @@ -11,5 +11,10 @@ profile = ["gpui-kit/profiler"] arena-tracker-core = { path = "../core" } gpui-kit = "=0.9.1" +[dev-dependencies] +# The GPUI that gpui-kit pins (upgrade them together), for its test context. Not gpui-kit's own +# test-support: its gpui-fast features would force older wgpu and others into Cargo.lock. +gpui = { package = "gpui-pre", version = "=0.3.12", features = ["test-support"] } + [build-dependencies] embed-resource = "3.0.12" diff --git a/crates/app/src/champion_table.rs b/crates/app/src/champion_table.rs index bc0f921..3175be4 100644 --- a/crates/app/src/champion_table.rs +++ b/crates/app/src/champion_table.rs @@ -1,8 +1,12 @@ -//! The champion table: one row per champion, virtualised by the component. +//! The champion table: one row per champion, only the visible rows built (issue #31: a row is +//! one element per cell, unlike gpui-component's DataTable, which costs a layout per cell). + +use std::ops::Range; use arena_tracker_core::{ChampionRow, Column as SortKey, Date, sort_rows}; -use gpui_kit::component::table::{Column, ColumnSort, TableDelegate, TableState}; -use gpui_kit::component::{ActiveTheme as _, StyledExt as _}; +use gpui_kit::component::scroll::Scrollbar; +use gpui_kit::component::{ActiveTheme as _, Icon, IconName, StyledExt as _}; +use gpui_kit::prelude::FluentBuilder as _; use gpui_kit::*; use crate::text::{decimal, state_label}; @@ -34,8 +38,7 @@ const SPECS: [Spec; 9] = [ spec("Tentatives", SortKey::Attempts, 110., true), spec("Dernière Partie", SortKey::LastMatch, 150., true), ]; -/// Hidden outside a Season, where there is no Challenge. -const ATTEMPTS: usize = 7; +const ROW_HEIGHT: f32 = 32.; const PORTRAIT: f32 = 24.; pub struct ChampionTable { @@ -43,6 +46,9 @@ pub struct ChampionTable { in_season: bool, /// The user's choice; `None` means the default for the view. sort: Option<(SortKey, bool)>, + /// The clicked champion's id: it stays selected through sorting and reloads. + selected: Option, + scroll: UniformListScrollHandle, } impl ChampionTable { @@ -51,6 +57,8 @@ impl ChampionTable { rows: Vec::new(), in_season: false, sort: None, + selected: None, + scroll: UniformListScrollHandle::new(), } } @@ -77,9 +85,122 @@ impl ChampionTable { sort_rows(&mut self.rows, key, descending); } - fn spec(&self, col_ix: usize) -> &'static Spec { - &SPECS[col_ix + usize::from(!self.in_season && col_ix >= ATTEMPTS)] + /// A header click cycles descending, ascending, then back to the view's default order. + fn sort_by(&mut self, key: SortKey) { + self.sort = match self.sorted_by() { + (sorted, true) if sorted == key => Some((key, false)), + (sorted, false) if sorted == key => None, + _ => Some((key, true)), + }; + self.resort(); } + + /// The Attempts column only exists in a Season, where there is a Challenge. + fn columns(&self) -> impl Iterator + use<> { + let in_season = self.in_season; + SPECS + .iter() + .filter(move |spec| in_season || spec.key != SortKey::Attempts) + } + + fn header(&self, cx: &mut Context) -> impl IntoElement { + let theme = cx.theme(); + let (head, foreground, border, muted) = ( + theme.table_head, + theme.table_head_foreground, + theme.border, + theme.muted_foreground, + ); + let (sorted, descending) = self.sorted_by(); + div() + .h_flex() + .w_full() + .flex_shrink_0() + .h(px(ROW_HEIGHT)) + .pr(Scrollbar::width()) + .border_b_1() + .border_color(border) + .bg(head) + .text_color(foreground) + .children(self.columns().map(|spec| { + let icon = match spec.key { + key if key == sorted && descending => IconName::SortDescending, + key if key == sorted => IconName::SortAscending, + _ => IconName::ChevronsUpDown, + }; + cell(spec) + .id(spec.title) + .gap_1() + .cursor_pointer() + .on_click(cx.listener(move |table, _, _, cx| { + table.sort_by(spec.key); + cx.notify(); + })) + .child(spec.title) + .child( + Icon::new(icon) + .size_3() + .when(spec.key != sorted, |icon| icon.text_color(muted)), + ) + })) + } + + fn row(&self, ix: usize, cx: &mut Context) -> AnyElement { + let theme = cx.theme(); + let row = &self.rows[ix]; + let id = row.champion.id; + let selected_bg = if theme.list.active_highlight { + theme.tokens.table_active + } else { + theme.tokens.accent + }; + div() + .id(ix) + .h_flex() + .w_full() + .h(px(ROW_HEIGHT)) + .pr(Scrollbar::width()) + .border_b_1() + .border_color(theme.table_row_border) + .when(ix % 2 == 1, |tr| tr.bg(theme.tokens.table_even)) + .map(|tr| { + if self.selected == Some(id) { + tr.bg(selected_bg) + } else { + tr.hover(|style| style.bg(theme.tokens.table_hover)) + } + }) + .on_click(cx.listener(move |table, _, _, cx| { + table.selected = Some(id); + cx.notify(); + })) + .children(self.columns().map(|spec| { + let td = cell(spec); + if spec.key != SortKey::Champion { + return td.child(cell_text(row, spec.key)); + } + let portrait = match &row.portrait { + Some(path) => img(path.clone()).size(px(PORTRAIT)).into_any_element(), + None => div().size(px(PORTRAIT)).bg(theme.border).into_any_element(), + }; + td.gap_2().child(portrait).child(row.champion.name.clone()) + })) + .into_any_element() + } +} + +/// A cell of `spec`'s column, header or body: fixed width, shrinking with the window. +// Text past it is clipped: an ellipsis (`text_ellipsis`) cost 0.2 ms per frame (#31). +fn cell(spec: &Spec) -> Div { + div() + .h_flex() + .w(px(spec.width)) + .min_w_0() + .h_full() + .px_2() + .overflow_hidden() + .whitespace_nowrap() + .when(spec.numeric, |td| td.justify_end()) } fn or_dash(value: Option) -> String { @@ -100,101 +221,70 @@ fn cell_text(row: &ChampionRow, key: SortKey) -> String { } } -impl TableDelegate for ChampionTable { - fn columns_count(&self, _: &App) -> usize { - SPECS.len() - usize::from(!self.in_season) - } - - fn rows_count(&self, _: &App) -> usize { - self.rows.len() - } - - fn column(&self, col_ix: usize, _: &App) -> Column { - let spec = self.spec(col_ix); - let column = Column::new(spec.title, spec.title).width(px(spec.width)); - let column = if spec.numeric { - column.text_right() +impl Render for ChampionTable { + fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { + let theme = cx.theme(); + let (background, border, radius, muted) = ( + theme.table, + theme.border, + theme.radius, + theme.muted_foreground, + ); + let body = if self.rows.is_empty() { + div() + .flex_1() + .flex() + .items_center() + .justify_center() + .text_color(muted) + .child("Aucun champion à afficher") + .into_any_element() } else { - column - }; - let (sorted_key, descending) = self.sorted_by(); - match spec.key { - key if key == sorted_key && descending => column.descending(), - key if key == sorted_key => column.ascending(), - _ => column.sortable(), - } - } - - // The table cycles a header descending, ascending, then back to `Default`: the view's - // default order. - fn perform_sort( - &mut self, - col_ix: usize, - sort: ColumnSort, - _: &mut Window, - cx: &mut Context>, - ) { - let key = self.spec(col_ix).key; - self.sort = match sort { - ColumnSort::Default => None, - ColumnSort::Ascending => Some((key, false)), - ColumnSort::Descending => Some((key, true)), - }; - self.resort(); - cx.notify(); - } - - fn render_td( - &mut self, - row_ix: usize, - col_ix: usize, - _: &mut Window, - cx: &mut Context>, - ) -> impl IntoElement { - let row = &self.rows[row_ix]; - let key = self.spec(col_ix).key; - if key != SortKey::Champion { - return cell_text(row, key).into_any_element(); - } - let portrait = match &row.portrait { - Some(path) => img(path.clone()).size(px(PORTRAIT)).into_any_element(), - None => div() - .size(px(PORTRAIT)) - .bg(cx.theme().border) - .into_any_element(), - }; - div() - .h_flex() - .items_center() - .gap_2() - .child(portrait) - .child(row.champion.name.clone()) + uniform_list( + "champions", + self.rows.len(), + cx.processor(|table, range: Range, _, cx| { + range.map(|ix| table.row(ix, cx)).collect::>() + }), + ) + .flex_1() + .track_scroll(&self.scroll) .into_any_element() - } - - fn render_empty( - &mut self, - _: &mut Window, - cx: &mut Context>, - ) -> impl IntoElement { + }; div() + .v_flex() + .relative() .size_full() - .flex() - .items_center() - .justify_center() - .text_color(cx.theme().muted_foreground) - .child("Aucun champion à afficher") + .overflow_hidden() + .text_sm() + .bg(background) + .border_1() + .border_color(border) + .rounded(radius) + .child(self.header(cx)) + .child(body) + .when(!self.rows.is_empty(), |table| { + table.child( + div() + .absolute() + .top(px(ROW_HEIGHT)) + .right_0() + .bottom_0() + .w(Scrollbar::width()) + .child(Scrollbar::vertical(&self.scroll)), + ) + }) } } #[cfg(test)] -mod tests { +pub(crate) mod tests { use arena_tracker_core::{Champion, ChampionRow, ChampionState}; // Explicit imports: a glob of `gpui_kit` would shadow the built-in `#[test]`. - use super::{ATTEMPTS, ChampionTable, SortKey, cell_text}; + use super::{ChampionTable, SortKey, cell_text}; - fn row(name: &str) -> ChampionRow { + pub(crate) fn row(name: &str) -> ChampionRow { ChampionRow { champion: Champion { id: 1, @@ -247,8 +337,24 @@ mod tests { #[test] fn attempts_column_is_hidden_outside_a_season() { let mut table = ChampionTable::new(); - assert_eq!(table.spec(ATTEMPTS).key, SortKey::LastMatch); + assert!(table.columns().all(|spec| spec.key != SortKey::Attempts)); table.set_rows(vec![], true); - assert_eq!(table.spec(ATTEMPTS).key, SortKey::Attempts); + assert!(table.columns().any(|spec| spec.key == SortKey::Attempts)); + } + + #[test] + fn a_header_cycles_descending_ascending_then_the_default_order() { + let mut table = ChampionTable::new(); + table.set_rows(vec![], true); + assert_eq!(table.sorted_by(), (SortKey::Attempts, true)); + table.sort_by(SortKey::Wins); + assert_eq!(table.sorted_by(), (SortKey::Wins, true)); + table.sort_by(SortKey::Wins); + assert_eq!(table.sorted_by(), (SortKey::Wins, false)); + table.sort_by(SortKey::Wins); + assert_eq!(table.sorted_by(), (SortKey::Attempts, true)); + // The default column starts descending, so its first click turns it ascending. + table.sort_by(SortKey::Attempts); + assert_eq!(table.sorted_by(), (SortKey::Attempts, false)); } } diff --git a/crates/app/src/stats_page.rs b/crates/app/src/stats_page.rs index 4bc11dd..2fafc1a 100644 --- a/crates/app/src/stats_page.rs +++ b/crates/app/src/stats_page.rs @@ -14,7 +14,6 @@ use gpui_kit::component::button::Button; use gpui_kit::component::chart::{AreaChart, BarChart}; use gpui_kit::component::select::{Select, SelectEvent, SelectItem, SelectState}; use gpui_kit::component::tab::{Tab, TabBar}; -use gpui_kit::component::table::{DataTable, TableState}; use gpui_kit::component::{ActiveTheme as _, Disableable as _, IndexPath, Sizable as _}; use gpui_kit::prelude::FluentBuilder as _; use gpui_kit::*; @@ -26,7 +25,9 @@ use crate::worker::{Msg, RefreshGate, spawn_refresh, spawn_statistics}; const ALL_SEASONS: &str = "Toutes les Saisons"; const ALL_FORMATS: &str = "Tous les Formats"; const NO_MATCH: &str = "Aucune Partie"; -const CHART_HEIGHT: f32 = 150.; +/// Fixed, as a cached view's height must be. With `card`'s padding, gap and title, it leaves +/// each chart 150 px: change them together. +const CHARTS_HEIGHT: f32 = 206.; /// While an import runs, the page is recomputed at most this often. const RELOAD_EVERY: Duration = Duration::from_secs(1); @@ -111,8 +112,8 @@ pub struct StatsPage { season_select: Entity>>, format_select: Entity>>, format_names: Vec, - table: Entity>, - table_in_season: bool, + charts: Entity, + table: Entity, _subscriptions: Vec, _listener: Task<()>, } @@ -170,8 +171,8 @@ impl StatsPage { let format_names = vec![SharedString::from(ALL_FORMATS)]; let format_select = cx .new(|cx| SelectState::new(format_names.clone(), Some(IndexPath::new(0)), window, cx)); - let table = - cx.new(|cx| TableState::new(ChampionTable::new(), window, cx).col_movable(false)); + let charts = cx.new(|_| ChartsRow::new()); + let table = cx.new(|_| ChampionTable::new()); let subscriptions = vec![ cx.subscribe_in( @@ -260,8 +261,8 @@ impl StatsPage { season_select, format_select, format_names, + charts, table, - table_in_season: false, _subscriptions: subscriptions, _listener: listener, }; @@ -287,6 +288,11 @@ impl StatsPage { self.progress.is_some() || self.refresh.running() || self.pending_round } + /// Whether one Season is selected, rather than all of them: only a Season has a Challenge. + fn in_season(&self) -> bool { + matches!(self.season, SeasonScope::Season(_)) + } + /// The Account shown: the pinned one, else the one being updated. fn viewed(&self) -> Option<&Account> { self.pinned @@ -508,8 +514,12 @@ impl StatsPage { self.show_statistics(window, cx); } - /// Shows `stats`: the Format choices and the table. + /// Shows `stats`: the Format choices, the charts and the table. fn show_statistics(&mut self, window: &mut Window, cx: &mut Context) { + let charts = self.stats.as_ref().map(|s| &s.charts); + let in_season = self.in_season(); + self.charts + .update(cx, |row, cx| row.set(charts, in_season, cx)); let mut names = vec![SharedString::from(ALL_FORMATS)]; names.extend( self.stats @@ -528,15 +538,9 @@ impl StatsPage { fn refresh_table(&mut self, cx: &mut Context) { let rows = self.stats.iter().flat_map(|s| &s.rows); let rows = rows.filter(|row| self.filter.keeps(row)).cloned().collect(); - let in_season = matches!(self.season, SeasonScope::Season(_)); - // Only a change of columns needs `refresh`, which also resets the column widths. - let columns_changed = in_season != self.table_in_season; - self.table_in_season = in_season; + let in_season = self.in_season(); self.table.update(cx, |table, cx| { - table.delegate_mut().set_rows(rows, in_season); - if columns_changed { - table.refresh(cx); - } + table.set_rows(rows, in_season); cx.notify(); }); } @@ -669,6 +673,7 @@ fn card( .v_flex() .flex_1() .min_w_0() + .h_full() .gap_2() .p_3() .border_1() @@ -680,7 +685,103 @@ fn card( .font_weight(FontWeight::SEMIBOLD) .child(title), ) - .child(div().h(px(CHART_HEIGHT)).w_full().children(Some(body))) + .child(div().flex_1().min_h_0().w_full().children(Some(body))) +} + +/// The charts, a cached view: hovering the table, which redraws the page, does not draw them +/// again (#31). The page updates it from `show_statistics`. +struct ChartsRow { + /// Empty when there are no statistics. + charts: Charts, + in_season: bool, + /// Guards the cache in tests. + #[cfg(test)] + renders: usize, +} + +impl ChartsRow { + fn new() -> ChartsRow { + ChartsRow { + charts: Charts { + placements: vec![], + completed_over_time: vec![], + attempts_to_complete: [0; 5], + }, + in_season: false, + #[cfg(test)] + renders: 0, + } + } + + /// Shows `charts`, or none; drawing them again only when they changed, since reloads keep + /// coming during an import. + fn set(&mut self, charts: Option<&Charts>, in_season: bool, cx: &mut Context) { + let charts = charts.cloned().unwrap_or_else(|| ChartsRow::new().charts); + if (&self.charts, self.in_season) != (&charts, in_season) { + self.charts = charts; + self.in_season = in_season; + cx.notify(); + } + } +} + +impl Render for ChartsRow { + fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { + #[cfg(test)] + { + self.renders += 1; + } + let (border, muted) = { + let theme = cx.theme(); + (theme.border, theme.muted_foreground) + }; + let charts = &self.charts; + let mut cards = vec![ + card( + "Répartition des Placements", + if shown("placements") { + placements_chart(charts) + } else { + Some(div().size_full().into_any_element()) + }, + NO_MATCH, + border, + muted, + ) + .into_any_element(), + ]; + if self.in_season { + cards.push( + card( + "Champions validés au fil de la Saison", + if shown("completed") { + completed_chart(charts) + } else { + Some(div().size_full().into_any_element()) + }, + "Aucun champion validé", + border, + muted, + ) + .into_any_element(), + ); + cards.push( + card( + "Tentatives pour valider", + if shown("attempts") { + attempts_chart(charts) + } else { + Some(div().size_full().into_any_element()) + }, + "Aucun champion validé", + border, + muted, + ) + .into_any_element(), + ); + } + div().h_flex().size_full().gap_3().children(cards) + } } fn placements_chart(charts: &Charts) -> Option { @@ -744,60 +845,9 @@ impl Render for StatsPage { let theme = cx.theme(); (theme.border, theme.muted_foreground) }; - let in_season = matches!(self.season, SeasonScope::Season(_)); - let options = filters(in_season); + let options = filters(self.in_season()); let selected = options.iter().position(|(_, f)| *f == self.filter); - let empty = Charts { - placements: vec![], - completed_over_time: vec![], - attempts_to_complete: [0; 5], - }; - let charts = self.stats.as_ref().map_or(&empty, |s| &s.charts); let challenge = self.stats.as_ref().and_then(|s| s.challenge.as_ref()); - let mut cards = vec![ - card( - "Répartition des Placements", - if shown("placements") { - placements_chart(charts) - } else { - Some(div().size_full().into_any_element()) - }, - NO_MATCH, - border, - muted, - ) - .into_any_element(), - ]; - if in_season { - cards.push( - card( - "Champions validés au fil de la Saison", - if shown("completed") { - completed_chart(charts) - } else { - Some(div().size_full().into_any_element()) - }, - "Aucun champion validé", - border, - muted, - ) - .into_any_element(), - ); - cards.push( - card( - "Tentatives pour valider", - if shown("attempts") { - attempts_chart(charts) - } else { - Some(div().size_full().into_any_element()) - }, - "Aucun champion validé", - border, - muted, - ) - .into_any_element(), - ); - } let busy = self.busy(); let status_line = sync_line(busy, self.progress, self.crashed, self.stored); @@ -883,7 +933,11 @@ impl Render for StatsPage { .when(shown("tiles"), |page| { page.children(challenge.map(|c| challenge_tiles(c, self.official(), border, muted))) }) - .child(div().h_flex().gap_3().children(cards)) + .child( + self.charts + .clone() + .cached(StyleRefinement::default().w_full().h(px(CHARTS_HEIGHT))), + ) .when(shown("tabs"), |page| { page.child( TabBar::new("state-filter") @@ -891,8 +945,7 @@ impl Render for StatsPage { .selected_index(selected.unwrap_or(0)) .children(options.iter().map(|(label, _)| Tab::new().label(*label))) .on_click(cx.listener(|this, ix: &usize, _, cx| { - let in_season = matches!(this.season, SeasonScope::Season(_)); - if let Some((_, filter)) = filters(in_season).get(*ix) { + if let Some((_, filter)) = filters(this.in_season()).get(*ix) { this.filter = *filter; this.refresh_table(cx); cx.notify(); @@ -901,12 +954,88 @@ impl Render for StatsPage { ) }) .when(shown("table"), |page| { - page.child( - div() - .flex_1() - .min_h(px(240.)) - .child(DataTable::new(&self.table).stripe(true)), - ) + page.child(div().flex_1().min_h(px(240.)).child(self.table.clone())) }) } } + +#[cfg(test)] +mod tests { + use std::cell::Cell; + use std::path::Path; + use std::rc::Rc; + use std::sync::Arc; + + use arena_tracker_core::{RiotApi, Tracker}; + use gpui_kit::base::async_util::unbounded; + use gpui_kit::{ + AppContext as _, Bounds, Modifiers, TestAppContext, VisualTestContext, WindowBounds, + WindowOptions, point, px, size, + }; + + use super::StatsPage; + use crate::champion_table::tests::row; + + // No test can time a frame: this guards the cache that keeps hovering cheap instead (rule #1, + // #31). It runs with the app's tests on Windows; CI only builds the core. + #[gpui::test] + fn hovering_the_table_does_not_render_the_charts(cx: &mut TestAppContext) { + cx.update(gpui_kit::init); + let tracker = Arc::new( + Tracker::open( + Path::new(":memory:"), + Box::new(RiotApi::new(String::new(), "europe")), + ) + .unwrap() + .with_seasons(Vec::new()), + ); + let (window, page) = cx.update(|cx| { + let (tx, rx) = unbounded(); + let bounds = Bounds { + origin: point(px(0.), px(0.)), + size: size(px(1280.), px(860.)), + }; + let options = WindowOptions { + window_bounds: Some(WindowBounds::Windowed(bounds)), + ..Default::default() + }; + gpui_kit::open_window(options, cx, |window, cx| { + cx.new(|cx| StatsPage::new(tracker, None, false, rx, tx, window, cx)) + }) + .unwrap() + }); + let cx = &mut VisualTestContext::from_window(window, cx); + let (table, charts) = + page.read_with(cx, |page, _| (page.table.clone(), page.charts.clone())); + // Enough rows to fill the table, under the points hovered below. + table.update(cx, |table, cx| { + let rows = (1..=20).map(|n| row(&format!("Champion {n}"))); + table.set_rows(rows.collect(), false); + cx.notify(); + }); + cx.update(|window, cx| window.draw(cx).clear(cx)); + let renders = charts.read_with(cx, |charts, _| charts.renders); + assert!(renders > 0); + + // A row's hover style notifies the table, which redraws the page. + let hovers = Rc::new(Cell::new(0)); + let _subscription = cx.update(|_, cx| { + let hovers = hovers.clone(); + cx.observe(&table, move |_, _| hovers.set(hovers.get() + 1)) + }); + for y in [700., 740.] { + cx.simulate_mouse_move(point(px(300.), px(y)), None, Modifiers::none()); + cx.update(|window, cx| window.draw(cx).clear(cx)); + } + assert!(hovers.get() > 0, "no row was hovered"); + assert_eq!(charts.read_with(cx, |charts, _| charts.renders), renders); + + // The count does move when the charts change. + charts.update(cx, |_, cx| cx.notify()); + cx.update(|window, cx| window.draw(cx).clear(cx)); + assert_eq!( + charts.read_with(cx, |charts, _| charts.renders), + renders + 1 + ); + } +} diff --git a/docs/performance.md b/docs/performance.md index f3b43fe..b4ac54a 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -10,13 +10,13 @@ Measured on the **reference machine**, on a **release build** (`scripts/prod run | # | Budget | Limit | Current value | Status | | --- | --- | --- | --- | --- | -| 1 | Interactions (hover, scroll, sort, filter, moving or resizing the window): cost of one frame | at most **2 ms** at the 99th percentile, aiming for 1 ms | 5–7 ms for a full frame of the statistics page; a window move redraws one, 5–8 ms per move at the 95th percentile | over budget | +| 1 | Interactions (hover, scroll, sort, filter, moving or resizing the window): cost of one frame | at most **2 ms** at the 99th percentile, aiming for 1 ms | 5–7 ms for a full frame of the statistics page; a window move redraws one, 5–8 ms per move at the 95th percentile (before #31) | over budget; to re-measure since #31 | | 2 | Idle, window visible: CPU | at most **0.5 %** of one core on average | 0.3–1.4 % (about 0.8 %) | over budget | | 3 | Window minimised or hidden | **no rendering**, CPU close to 0, outside an import | not measured | unknown | | 4 | Memory, with the full page loaded (every champion and portrait) | at most **150 MB** working set | 120 MB working set, 99 MB private | within budget | | 5 | Background work (import, following the game client) | threads at **low priority**, never more than **one core** | not measured | unknown | -Current values measured on 2026-11-16 and 2026-11-17 (issue #17). +Current values measured on 2026-11-16 and 2026-11-17 (issue #17). For information, #31 made a full frame about a third cheaper on the manual checks machine (drawing it: 2.37 → 1.57 ms at the median, 3.72 → 2.50 ms at the 99th percentile, plus 0.22 ms of presentation); its value here is still to measure. ### Ratchet @@ -37,6 +37,6 @@ Every change that touches rendering, background work or memory measures before a - **Champion table hover**: `powershell.exe -ExecutionPolicy Bypass -File scripts/hover-probe.ps1 -Title "Arena Tracker"` from WSL, with the statistics page showing the table under the default band (adjust `-Top` and `-Bottom` otherwise). After an idle phase, it posts synthetic mouse moves across table rows 240 times per second without touching the real cursor. Compare `HOVER cpu` with `IDLE cpu`; `HOVER ping` shows how long input waits behind the UI thread while hovering (budget 1). The default band is `-X 0.25 -Top 0.62 -Bottom 0.95 -Step 0.04` (fractions of the client area, about one row per move in a window at least 800 px tall). Leave the real cursor still over the window, outside the table: when it is outside the window, GPUI sees each synthetic move as the mouse entering then leaving, and refreshes the whole window, bypassing cached views. - **Where a frame goes**: build with `scripts/prod build --features profile` (never for everyday use) and start the app with `ARENA_TRACKER_PROFILE=` (from WSL, pass it through `WSLENV`, e.g. `WSLENV=ARENA_TRACKER_PROFILE/p:ARENA_TRACKER_HIDE`). Every second it appends the frames GPUI drew (`draw`: total, `request_layout`, `prepaint`, `paint` in ms), their presentation (`present`) and the views' own time (`view`, recorded by GPUI from 0.5 ms). `ARENA_TRACKER_HIDE=`, read at start, removes parts of the page so that a part's cost is the difference with the full page under the hover probe: `header`, `banners`, `tiles`, `placements`, `completed`, `attempts` (the three charts keep their height), `tabs`, `table`. - **Memory**: working set of `arena-tracker.exe` in Task Manager, or `Get-Process arena-tracker` in PowerShell, once the page is fully loaded. -- **CI cannot check budgets**: its runner is Linux without a GPU, and the app only builds on Windows (ADR-0003). When a change relies on cached views to stay within budget, a structural test (for example, "hovering the table does not render the charts") guards it instead of a timed test. +- **CI cannot check budgets**: its runner is Linux without a GPU, and the app only builds on Windows (ADR-0003). When a change relies on cached views to stay within budget, a structural test (for example, "hovering the table does not render the charts") guards it instead of a timed test. The charts row is the page's one cached view (#31). A cached view is laid out from its style alone, never its content, so only a part whose size does not depend on its content can be one. A view that is not cached renders again with its parent and saves nothing, while its state must be kept in sync; a window move bypasses every cache. GPUI and gpui-component are not modified to meet a budget: the app's own rendering cost is the lever (ADR-0004).