hojicha-rendering

Crates.iohojicha-rendering
lib.rshojicha-rendering
version0.2.1
created_at2025-08-18 03:03:00.687986+00
updated_at2025-08-18 03:03:00.687986+00
descriptionHigh-performance rendering optimization for Hojicha TUI framework
homepagehttps://jgok76.gitea.cloud/femtomc/hojicha
repositoryhttps://jgok76.gitea.cloud/femtomc/hojicha
max_upload_size
id1799890
size153,002
McCoy R. Becker (femtomc)

documentation

https://docs.rs/hojicha

README

hojicha-rendering

High-performance rendering optimization for the Hojicha TUI framework.

Features

  • Differential Rendering: Only redraw changed regions of the screen
  • Render Caching: Cache and reuse rendered components
  • Region Coalescing: Merge overlapping dirty regions for efficiency
  • Component Dependencies: Track and cascade updates through dependencies
  • Checksum-based Change Detection: Detect actual content changes

Quick Start

use hojicha_rendering::prelude::*;
use ratatui::layout::Rect;

// Create a differential renderer
let mut renderer = DifferentialRenderer::new();

// Register UI components
renderer.register_component("header", Rect::new(0, 0, 80, 3));
renderer.register_component("content", Rect::new(0, 3, 80, 20));

// Mark components as dirty when they change
renderer.mark_component_dirty("content");

// Check if rendering is needed
if renderer.component_needs_render("content") {
    // Render the component
    render_content();
    
    // Mark as rendered
    renderer.mark_component_rendered("content", None);
}

Performance

Based on our benchmarks:

  • Mark 10 regions: 224 ns (45M ops/sec)
  • Mark 100 regions: 1.78 µs (56M ops/sec)
  • Mark 1000 regions: 16.9 µs (59M ops/sec)

In typical applications with 20% of components changing per frame:

  • 87% reduction in render calls
  • 88% reduction in terminal cell updates
  • <0.01% frame time overhead

Examples

Run the performance comparison:

cargo run --example performance_comparison

Architecture

The crate is organized into three main modules:

  • differential: Core differential rendering system with dirty region tracking
  • cache: LRU cache for rendered components
  • algorithms: Geometric algorithms for rectangle operations

License

GPL-3.0

Commit count: 0

cargo fmt