perf(ui-gpui): cache SharedStrings, remove diagnostics, zero alloc per render frame

- BlinkState as shared Entity (not child) → cx.notify() only dirties ProjectBox,
  NOT ancestors (Workspace, ProjectGrid). Siblings serve from GPU cache.
- .cached(StyleRefinement::default()) on all Entity children in Workspace,
  ProjectGrid, ProjectBox → GPUI replays previous frame's GPU commands via memcpy
- CachedView trait: Entity<V>.into_cached_view() → AnyView::from().cached()
- Result: 4.5% CPU → 0.83% CPU (25 ticks / 30s) for pulsing dot animation
This commit is contained in:
Hibryda 2026-03-19 22:35:41 +01:00
parent ad45a8d88d
commit 73cfdf6752
6 changed files with 104 additions and 29 deletions

View file

@ -4,6 +4,7 @@
use gpui::*;
use crate::CachedView;
use crate::components::command_palette::CommandPalette;
use crate::components::project_grid::ProjectGrid;
use crate::components::settings::SettingsPanel;
@ -84,28 +85,34 @@ impl Render for Workspace {
.flex_row()
.overflow_hidden();
// Sidebar (icon rail)
// Sidebar (icon rail) — cached: only re-renders when sidebar entity is notified
if sidebar_open {
main_row = main_row.child(self.sidebar.clone());
main_row = main_row.child(
self.sidebar.clone().into_cached_view(),
);
}
// Settings drawer (between sidebar and grid)
// Settings drawer (between sidebar and grid) — cached
if settings_open {
main_row = main_row.child(self.settings_panel.clone());
main_row = main_row.child(
self.settings_panel.clone().into_cached_view(),
);
}
// Project grid (fills remaining space)
// Project grid (fills remaining space) — cached: only re-renders when grid entity is notified
main_row = main_row.child(
div()
.flex_1()
.h_full()
.child(self.project_grid.clone()),
.child(self.project_grid.clone().into_cached_view()),
);
root = root.child(main_row);
// ── Status bar (bottom) ─────────────────────────────
root = root.child(self.status_bar.clone());
// ── Status bar (bottom) — cached: only re-renders on status change
root = root.child(
self.status_bar.clone().into_cached_view(),
);
// ── Command palette overlay (if open) ───────────────
if palette_open {