Performance Unnecessary Work

Use Jeff Dean and Sanjay Ghemawat's canonical guidance on avoiding unnecessary work. Use when adding fast paths, hoisting loop invariants, deferring computation, specializing code, caching, helping the compiler, or reducing statistics and logging overhead.

boshjerns 03e76d9 2 files · 1.3 KB Updated

File contents

Avoid unnecessary work

Read the exact current source section before applying it:

python3 ~/.codex/skills/performance-hints/scripts/fetch_section.py avoid-unnecessary-work --output text

Canonical section: Avoid unnecessary work

Attribute the guidance to Jeff Dean and Sanjay Ghemawat. Do not assume every hint applies: inspect the code, identify the relevant cost, and measure or estimate before recommending a change.

This section includes:

  • Fast paths for common cases
  • Precompute expensive information once
  • Move expensive computations outside loops
  • Defer expensive computation
  • Specialize code
  • Use caching to avoid repeated work
  • Make the compiler’s job easier
  • Reduce stats collection costs
  • Avoid logging on hot code paths

boshjerns/performance-hints-agent-skills/tree/main/skills/performance-unnecessary-work commit 03e76d9c37

Frequently asked questions

npx skillmds@latest add boshjerns/performance-unnecessary-work