Perf

From nicolaiprodromov/puree · View interactive version

Perf is an AI agent skill from the GitHub repository nicolaiprodromov/puree. Profile and optimize Puree engine performance. Covers GPU rendering bottlenecks, layout computation, buffer packing, container count, and frame timing.

How to use this skill

Skill file

Profile and fix performance bottlenecks in the Puree engine itself. This is for framework-level optimization, not user-level UI simplification (use the optimize skill for that).

Procedure

1. Identify the Bottleneck Layer

Performance in Puree breaks down into:

| Phase | Typical Cost | Module |

|-------|-------------|--------|

| SCSS compilation | 5–50ms (cached: <1ms) | native_bindings.SCSSCompiler |

| YAML parsing | 5–20ms | parser.py |

| CSS cascade | 2–10ms | native_bindings.SCSSCompiler |

| Layout (Taffy) | 1–15ms | stretchable FFI |

| Script execution | 1–5ms | compiler.py |

| Buffer packing | 1–10ms (scales with containers) | render.py |

| GPU upload | <1ms | render.py (SSBO update) |

| Compute shader | <1ms–5ms (scales with pixels) | shaders/container.glsl |

| Text rendering | 2–20ms (scales with text count) | text_op.py |

| Image loading | 10–100ms per image (first load) | img_op.py |

| Hit detection | <1ms | native_bindings.HitDetector |

2. Measure

Add timing to the suspected bottleneck:

import time
from .log import get_logger
logger = get_logger(__name__)

start = time.perf_counter()
# ... operation ...
elapsed = (time.perf_counter() - start) * 1000
logger.info(f"[PERF] operation_name: {elapsed:.2f}ms")

For frame timing, check render.py — it may already have timing hooks.

Use just tail to live-follow the log, or just logs to see recent output.

3. Common Optimizations

Buffer packing (render.py):

Layout (parser.py / stretchable):

SCSS compilation (native_bindings):

Text rendering (text_op.py):

Shader (container.glsl):

4. Verify

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.