Skip to content

Improve Performance#2

Merged
HALQME merged 12 commits intomainfrom
performance
Dec 15, 2025
Merged

Improve Performance#2
HALQME merged 12 commits intomainfrom
performance

Conversation

@HALQME
Copy link
Copy Markdown
Owner

@HALQME HALQME commented Dec 15, 2025

This pull request introduces several significant improvements and new features to the project, focusing on profiling and performance benchmarking, enhancements to the layout engine, and improvements to the build and CI workflows. The most important changes are grouped and summarized below:

Profiling and Performance Benchmarking:

  • Added a new profiling system with related scripts and documentation. This includes new scripts in package.json for running different types of performance tests, a new profiler integration in the application runtime (Profiler in app.ts), and a GitHub Actions workflow (profiler.yml) that runs benchmarks on pull requests and posts results as comments. [1]], [2]], [3]], [4]], [5]], [6]], [7]], [8]], [9]], [10]], [11]])

Layout Engine Enhancements:

  • Introduced a layoutBoundary feature for block elements, allowing the layout engine to limit the number of child elements rendered based on available space. This includes the new applyLayoutBoundaryToBlock and estimateChildLength functions and their integration into the layout computation. [1]], [2]], [3]], [4]], [5]], [6]])
  • Improved code formatting and readability in layout-related functions, such as resolvePadding and dimension resolution. [1]], [2]])

Build and CI Workflow Improvements:

  • Added new GitHub Actions workflows for build (build.yml), continuous integration (ci.yml), and performance benchmarking (profiler.yml). The CI workflow now includes linting, type checking, formatting, and tests, while the build workflow handles package builds. [1]], [2]], [3]])

Codebase Simplification and Refactoring:

  • Simplified exports in packages/btuin/src/index.ts by re-exporting the entire runtime module. [1]], [2]])
  • Removed duplicate or unnecessary code, such as the redundant resolvePadding function in renderer.ts. ([packages/btuin/src/layout/renderer.tsL5-L20])

Rendering Optimization:

These changes collectively improve the project's reliability, maintainability, and performance monitoring capabilities.

Add grapheme segmentation and width measurement and update FlatBuffer, grid,
diff and drawText to handle multi-code-point and wide glyphs. Cache layout
results in the render loop to avoid redundant layout computations. Add view
key-handler traversal, make Profiler use Bun's fs APIs, enable layout-engine
profiling, and update tests and profiles.
Implement a stateful, incremental layout engine with a wasm bridge
(init_layout_engine, update_nodes, remove_nodes, compute_layout by key) and
corresponding Rust stateful implementation.

Optimize renderer and buffers: track ASCII-only buffers with FlatBuffer, add
ASCII fast-path diffing, avoid diffing the same buffer instance, fall back to a
safe full redraw when diff output is empty, and ensure one frame is rendered on
mount.

Add showcase package and smoke tests (with exit timers) and include it in the
test script. Misc profiler and minor test adjustments.
Introduce layoutBoundary flag to LayoutStyle and a Block.boundary() helper.
Implement applyLayoutBoundaryToBlock and estimateChildLength to trim block
children when a block has layoutBoundary set. Add LayoutBoundary factory and
tests for trimming behavior.
Add scripts/profiler-limit.spec.ts and a "profiler:limit" npm script. Introduce
WARMUP_FRAMES in profiler-core.ts. Update profiler specs to assert startup
latency and steady-state metrics and call Bun.gc(true) before runs. Add clipping
early-return to renderElement to skip offscreen rendering. Apply minor
formatting and whitespace cleanup in layout and tests.
Add Rust toolchain and wasm-pack setup to CI and profiler workflows, and add a
pnpm step to build @btuin/layout-engine (WASM). Remove the explicit pnpm version
pin from the profiler workflow.
Repository owner deleted a comment from github-actions bot Dec 15, 2025
Repository owner deleted a comment from github-actions bot Dec 15, 2025
Replace CI's direct filtered command with a project build script that invokes
the @btuin/layout-engine via pnpm. Update package.json build to use pnpm
--filter @btuin/layout-engine build. Add "pkg" to .gitignore.
Repository owner deleted a comment from github-actions bot Dec 15, 2025
Bump oven-sh/setup-bun to v2 and pnpm/action-setup to v4 in workflow files
Replace Bun.$ mkdir and Bun.write in profiler.ts with node fs mkdirSync and
writeFileSync, add import and error handling. Also change profiler workflow
build step to use pnpm run build
Rename test variables to UPPER_CASE, use import.meta.dirname for profile output
paths, remove unused WARMUP_FRAMES, and update .gitignore to ignore nested
profiles JSON. Miscellaneous style and formatting fixes (semicolons, spacing,
minor console formatting).
@github-actions
Copy link
Copy Markdown

🚀 Performance Benchmark Result

          Performance Limits Report 5 runs
====================================================
| FPS Target | Avg Nodes |  Min  |  Max  | Std Dev |
|------------|-----------|-------|-------|---------|
| 120 FPS    | 1900      | 1000  | 2700  | ±651    |
|  60 FPS    | 4220      | 4000  | 4500  | ±204    |
|  30 FPS    | 8380      | 8100  | 8500  | ±147    |
|  15 FPS    | 16460     | 16100 | 16600 | ±185    |
====================================================
Run Details Triggered by commit: 015c962

@HALQME HALQME merged commit 661bc41 into main Dec 15, 2025
2 checks passed
@HALQME HALQME deleted the performance branch December 15, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant