OpenParable
Skip to content
← Back to skills

Perf Hotpath Guard

Testing & Quality
perf-hotpath-guard

Perf Hotpath Guard is an Agent Skill for testing & quality published in the abbaye/WpfHexEditorIDE repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

INTERNAL DEV WORKFLOW for WpfHexEditor — Claude self-invokes after editing C# in render/layout/scroll hot paths (HexEditor/, CodeEditor/Rendering*, *Viewport*, *GlyphRun*, *Renderer*, *ScrollHandler*, OnRender, MeasureOverride, ArrangeOverride) to detect allocations and patterns that cause jank or GC pressure. Skip on: tests, mocks, designer files, non-render code in non-hot directories.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/abbaye/WpfHexEditorIDE/blob/HEAD/Sources/.claude/skills/perf-hotpath-guard/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/perf-hotpath-guard, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

perf-hotpath-guard (internal)

Catches perf anti-patterns from project history (jank, GC pressure in render loops). Memory anchors: adr_006_zoom_rendering, adr_hexeditor_viewport_race, bug_drag_scroll_fix, feedback_wordwrap_column, bug_doc_editor_caret_hittest.

When I invoke

Trigger: .cs edits matching ANY of:

  • Path under HexEditor/ or CodeEditor/Rendering
  • Filename contains Viewport, GlyphRun, Renderer, ScrollHandler
  • Edit modifies OnRender, MeasureOverride, or ArrangeOverride

Skip if path contains Test, Mock, *.Designer.cs, *.g.cs, *.g.i.cs.

Pipeline

scripts/hotpath-scan.ps1 -Files <paths> (applies rules inside hot-method bodies only) → HotPath: <n> issues or OK.

9 rules

See references/perf-rules.md for regex + rationale.

RuleAnchor
alloc-in-renderGC pressure/jank
linq-in-hotallocations + delegate creation
string-concat-loopO(n²) allocations
boxingstruct→object passing
dispatcher-cosmeticfeedback_wordwrap_column anti-pattern
formatted-text-recreatebug_doc_editor_caret_hittest
glyph-run-recreaterender cost without pool
findvisualchild-renderO(n) tree walk every frame
regex-in-rendercompile cost on hot path

Hot methods (from references/hot-methods.md): OnRender, MeasureOverride, ArrangeOverride, OnPreviewMouseMove, OnScrollChanged, Render*/Draw*/Paint* in renderer files, any method preceded by // HOT. Exclude with // COLD.

Output

HotPath: 2 issues
  HexLineRenderer.cs:142  alloc-in-render         OnRender -> new SolidColorBrush(...)
  TextViewport.cs:88      formatted-text-recreate OnRender -> new FormattedText(...)

Suppress: // alloc-ok: <reason> (alloc-in-render), // COLD (exclude method), // HOT-EXCEPTION: <note> (document legitimate exception). Static analysis only — no runtime profiling, no code rewrite.