performance-fixer

Find and fix managed C# performance problems in SkiaSharp with benchmark and parity-test proof.

5.6k|645|Updated Feb 22, 2016
One-click install
npx skills add https://github.com/mono/SkiaSharp --skill performance-fixer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-fixer
Source: https://github.com/mono/SkiaSharp/tree/main/.agents/skills/performance-fixer
Command: npx skills add https://github.com/mono/SkiaSharp --skill performance-fixer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

SkiaSharp is a thin managed wrapper over native Skia, so its recurring performance problems live in the C# layer: P/Invoke transitions paid for trivial float math, allocations on hot parse paths, native lookups redone on every getter, and per-element marshalling in loops. This Skill systematically finds those issues and fixes them with rigorous proof.

Core Features & Use Cases

  • Scan mode: Hunts the SkiaSharp performance signature across five hot-path areas (geometry-math, color, handles-and-collections, text-and-fonts, pixels-and-images) using round-robin focus rotation and de-duplication against open issues and PRs.
  • Fix mode: Implements the minimal managed optimization, then proves it with two mandatory proofs — a BenchmarkDotNet New-vs-Old benchmark showing a repeatable speedup with no allocation regression, and an equivalence test asserting bit-exact parity with the native path across edge inputs.
  • Governed workflow: Enforces golden rules (one optimization per run, ABI stability, x87 float fallback, never edit generated or native code) and files a linked issue plus draft PR, or emits a noop when no convincing candidate exists.
  • Use Case: Ask the agent to scan SkiaSharp for performance opportunities; it identifies that a getter redoes a locked HandleDictionary lookup per call, benchmarks a cached-wrapper alternative, proves identical behavior, and opens a draft PR with the measured numbers.

Quick Start

Ask the agent to scan SkiaSharp for managed performance opportunities and fix the strongest candidate it finds.

Frequently Asked Questions about performance-fixer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find and fix performance problems in SkiaSharp?

Run the scan workflow, which rotates across five hot-path areas (geometry-math, color, handles-and-collections, text-and-fonts, pixels-and-images), establishes a realistic hot caller with file:line citations, then proves a speedup with BenchmarkDotNet before implementing a minimal managed fix.

How do I benchmark SkiaSharp code with BenchmarkDotNet?

Copy benchmarks/SkiaSharp.Benchmarks/Benchmarks/TemplateBenchmark.cs, write New vs Old methods in one process with [MemoryDiagnoser], and run dotnet run -c Release --project benchmarks/SkiaSharp.Benchmarks -- --filter '*YourBenchmark*'. Run at least twice and check Mean, Error, StdDev, and allocations.

Can this skill modify native Skia C++ code or generated bindings?

No. Scope is managed C# only in binding/** and source/**. Files under externals/skia/** and *.generated.cs are off-limits to edit or build, though the pinned Skia source may be read to verify invariants. Native-only fixes are filed as issues without a PR.

Why must a managed float math port keep a native fallback?

Managed float math is bit-exact with native Skia only on SSE2/NEON runtimes. x86 .NET Framework uses the x87 FPU with 80-bit intermediates, which diverges, so a RuntimeInformation-gated flag must route ported methods back through the native C API there.

What happens when the scan finds no performance opportunity?

Finding nothing is the expected outcome for a mature codebase. The run ends with a noop rather than manufacturing a marginal micro-win on a synthetic loop no real caller hits.