Skip to content

perf(render,runtime,term-state,terminal): release LTO/wgpu backend trim, zero-copy embedded font, 0 Hz idle watchdog, snapshot reuse, and persistent audio sampler #3129

Closed

Description

@Xuepoo

Priority: P1 | Area: area:runtime | Labels: feat, P1, area:runtime | Milestone: v0.1.0 | RFC: OQ-none | Task: CTX-1801

Summary

Land the targeted v0.0.41 binary-size, startup/scrollback memory (PB-2/PB-3), frame-handoff (PB-4), and idle-power (PB-7) optimizations across Cargo.toml, bitty-render, bitty-term-state, bitty-ui, bitty-runtime, and bitty-terminal:

  1. Release LTO & wgpu Target-OS Backend Trim (Cargo.toml, crates/bitty-render/Cargo.toml):
    • Enable lto = "thin" and codegen-units = 1 in [profile.release] alongside strip = "debuginfo" for cross-crate dead-code elimination and tighter codegen.
    • Configure wgpu = "26.0" with default-features = false, features = ["std", "parking_lot", "wgsl"] and enable only the target platform's native graphics backends (vulkan/gles on Linux/BSD, metal on macOS, dx12/vulkan on Windows), dropping webgpu and non-native HALs.
  2. Zero-Copy Static Embedded Symbols Font (crates/bitty-render/src/embedded.rs, crates/bitty-render/src/shaped.rs):
    • Register EMBEDDED_SYMBOLS_BYTES via fontdb::Source::Binary(Arc::new(EMBEDDED_SYMBOLS_BYTES)) instead of db.load_font_data(EMBEDDED_SYMBOLS_BYTES.to_vec()).
    • Change StoredFace::data in shaped.rs from Arc<Vec<u8>> to Arc<dyn AsRef<[u8]> + Send + Sync> so fontdb::Source::Binary(arc) shares the backing Arc without copying the 1.04 MiB .rodata font onto the heap.
  3. 0 Hz Idle Stall Watchdog (PB-7, crates/bitty-runtime/src/hang_watchdog.rs, crates/bitty-terminal/src/stall_watchdog.rs):
    • Park the stall-watchdog monitor thread indefinitely (PollTimeout::NONE on Unix self-pipe / Condvar::wait on non-Unix) when the main event loop is idle (!active), no PendingWork is armed, and all pending ticks/gaps have been drained.
    • Wake the monitor immediately on StallWatchdog::enter(phase), out-of-band HangGauges updates (finish_tick, set_pending_input, set_pending_replies, set_hidden_damage), SIGUSR1 (via signal_hook::low_level::pipe::register), or shutdown().
  4. Frame-Handoff & Viewport Allocation Elimination (PB-4, crates/bitty-term-state/src/{grid,state}.rs, crates/bitty-ui/src/view.rs, crates/bitty-runtime/src/runtime/present.rs):
    • Add Grid::copy_cells_into and State::snapshot_into(&self, dst: &mut Snapshot) to reuse an existing Box<[Cell]> buffer across same-dimension frames.
    • Defer self.state.snapshot() in Runtime::tick_at until after the idle short-circuit (present.rs:4048) and remove redundant snapshot.clone() calls on the primary view in view_viewport_has_visible_text (present.rs:4214) and the leaf render loop (present.rs:4795).
    • Replace let snap = state.snapshot(); in View::visible_cells (bitty-ui/src/view.rs:489) with direct zero-copy row borrows via state.live_grid_row(grid_row).
  5. Persistent Audio Sampling Worker (crates/bitty-runtime/src/plugin_runtime/audio.rs):
    • Replace per-poll std::thread::Builder::new().name("bitty-audio-sample").spawn(...) in SampledReads::request with a single lazily-spawned persistent worker thread per SampledReads instance woken over a bounded channel.

Activity

  1. added this to the v0.1.0 milestone on Nov 12, 2026
  2. added
    feat
    P1
    area:runtime
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:runtimefeat

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions