Index of every page on this site: llms.txt
All skills
daveebbelaar avatar

/performance

@22dc792
by Dave Ebbelaardaveebbelaar/bama1.9k stars
238
Run it yourself

Make a macOS app fast by measuring hangs, stutter, CPU, memory, and energy, then moving work off the main thread and onto the GPU. Use when the app freezes, a shortcut feels slow, dragging stutters, the fan spins, memory grows, or the user asks to optimize or profile.

Use this Skill: https://skilld.dev/gh/daveebbelaar/bama/performance

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈70 tokens for metadata: the name and description. ≈843 when used: this file. ≈4k more on demand in 3 files.

Description uses 3.5% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈282 characters, or 3.5%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Performance

Fast means two numbers: the first frame after a key press shows in under 100 ms, and nothing on the main thread blocks for more than 50 ms. Every change in this skill starts and ends with a measurement, so you know it helped. Symptom-by-symptom fixes are in recipes.md. For video, audio, camera, Metal, or large image pipelines, also read gpu-media.md.

The loop

reproduce -> measure (release build) -> find the line -> fix -> measure again -> commit with the numbers
  1. Reproduce. Write the exact steps, or add a probe command to the debug bridge (test-mac-app skill) that runs the slow action and logs the time of each step.

  2. Measure the release build. Debug Swift is 3 to 10 times slower and points at the wrong code.

  3. Find the line. Pick the tool for the symptom:

    Symptom Tool
    App freezes, spinning pointer sample <App> 5, then read the main thread stack
    Slow action Time Profiler: xcrun xctrace record --template 'Time Profiler' --attach <App> --time-limit 10s
    Short freezes while typing or dragging --template 'Hangs'
    Stutter while moving or animating --template 'Animation Hitches'
    Memory grows footprint <App>, leaks <App>, --template 'Allocations'
    Fan, battery --template 'Energy Log', look for timers and polling

    Read traces as text, not in the Instruments GUI: see "Measuring" in recipes.md. Delete every .trace after reading. A trace stores the app's full environment, and an app opened from an agent's shell inherits that shell's tokens. Never commit or share one.

  4. Fix with the matching recipe.

  5. Measure again with the same steps. Put before and after in the commit message: "Picker opens in 40 ms, was 600 ms".

The rules that fix most problems

  • Main thread does UI only. File, network, database, image decoding, Accessibility calls, and audio go elsewhere. A main-thread call that waits on another process (CoreAudio, AX) can freeze the app for minutes.
  • Show first, work after. Put the window or panel on screen in the same frame as the key press, then load. Never make the UI wait for the work.
  • Let the GPU composite. Large images go in a CALayer once. Pointer movement changes only small layers. Never redraw a full-screen picture per mouse event.
  • Decode at display size. ImageIO thumbnails, cached in NSCache.
  • Do not animate what must be fast. Search results and switchers update in place.
  • No polling without a reason. Timers get a tolerance and stop when nothing on screen needs them.

Apple silicon notes

  • Core Animation, Core Image (one shared CIContext), Vision, and AVFoundation already run on the GPU or the Neural Engine. Hand them the work instead of looping over pixels in Swift.
  • Write Metal (MTKView, compute shaders) only when a measurement shows Core Animation or Core Image is too slow. Most apps never need it.
  • Unified memory means a CGImage from ScreenCaptureKit passes to a layer without a copy. Keep it as a CGImage or IOSurface. Converting to NSImage and back costs copies.

Done when the slow action has a measured before and after, the after meets the two numbers at the top, and the commit message names both.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts28d3 checks · Risk SAFE
  • Gen Agent Trust Hub28d

    This skill provides architectural and performance optimization recipes for macOS development using standard Apple profiling tools. It includes proactive security warnings about handling trace files that might contain sensitive environment tokens.

  • Socket28d

    No alerts

  • Snyk28d

    Risk: LOW · No issues

Signed by skilld at 22dc792. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month

README badge

README badge for daveebbelaar/bama/performance