perf: Performance Improvements

Learn how to use the perf commit type for performance improvements. Understand when to use perf vs refactor, how to document benchmarks, and best practices.

Type Examples

Detailed Explanation

The perf Commit Type

The perf type indicates a code change that improves performance. Unlike refactor, which restructures code without changing behavior, perf specifically denotes that measurable performance characteristics have been improved. Under Semantic Versioning, perf commits typically do not trigger a version bump on their own (behavior is the same), but some teams configure them to trigger a patch bump.

Example Messages

perf: cache database queries for user profiles
perf(renderer): reduce DOM updates with virtual scrolling

When to Use perf

Use perf when your commit:

  • Reduces execution time or latency
  • Decreases memory usage or allocation
  • Reduces bundle size or network payload
  • Improves rendering or frame rates
  • Optimizes database queries or I/O operations

Documenting Performance Gains

Include benchmarks or metrics in the body:

perf(api): add response caching with Redis

Add a Redis cache layer for GET endpoints that
serve mostly static data. Cache TTL is 5 minutes.

Before: avg 120ms response time, 50 req/s
After:  avg 8ms response time (cache hit), 500 req/s

Cache miss still goes to the database with the
same ~120ms response time. Cache invalidation
happens on POST/PUT/DELETE to the same resource.

perf vs refactor

Use perf when... Use refactor when...
You optimized an algorithm You rewrote code for clarity
You added caching You extracted a helper function
You reduced bundle size You renamed variables
You have before/after metrics Behavior and performance are the same

Common Performance Verbs

cache     → Add caching layer
optimize  → Improve algorithm efficiency
reduce    → Decrease resource usage
lazy-load → Defer loading until needed
batch     → Combine multiple operations
memoize   → Cache function results

Use Case

You have optimized a database query that was causing slow page loads. By adding an index and restructuring the query, you reduced the average response time from 800ms to 50ms. You want a commit message that documents this improvement with concrete metrics so the team can see the impact.

Try It — Git Commit Message Generator

Open full tool