# 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.

- Skill: `boshjerns/performance-unnecessary-work` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add boshjerns/performance-unnecessary-work`
- Raw SKILL.md: https://api.skillmd.com/api/skills/boshjerns/performance-unnecessary-work/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: boshjerns (https://skillmd.com/u/boshjerns)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/boshjerns/performance-unnecessary-work

---


# Avoid unnecessary work

Read the exact current source section before applying it:

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

Canonical section: [Avoid unnecessary work](https://abseil.io/fast/hints#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


