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 Updated 1 repo stars
The Performance Hints page on the Abseil website, showing the title, authors, update date, and section navigation

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 commit 03e76d9c37

Frequently asked questions

npx get-skill add boshjerns/performance-unnecessary-work