Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to goperf will be documented in this file.

## [0.1.0] - 2026-01-05

### Added
- Initial release with 9 rule categories:
- **algorithm**: Nested range loops, linear search in loops
- **allocation**: Unpreallocated slices, string concatenation, map size hints
- **database**: SQL in loops (N+1), unbatched inserts, connection pool issues
- **concurrency**: Unbuffered channels, mutex in loops, goroutine leaks
- **io**: JSON in loops, HTTP client creation, ReadAll usage, body close
- **cache**: Repeated regexp/template compilation
- **context**: Background in handlers, missing timeouts, context leaks
- **memory**: pprof in hot paths, large struct copies
- **benchmark**: Functions needing benchmarks

- Output formats: `console`, `json`, `diff`
- CI integration with `--fail-on` threshold
- Auto-fix suggestions with `--fix` and `--dry-run`
- Ignore comments: `// perf:ignore`, `// perf:ignore-start/end`
- Smart detection to reduce false positives:
- Recognizes prepared statements in database loops
- Detects signal channels (`done`, `quit`, `ctx`)
- Identifies bounded loops with small iteration counts

### Dogfooding Results
Ran goperf on itself:
- **Before**: 147 issues (36 medium, 111 low)
- **Fixed**: 34 issues (slice preallocation, strings.Builder, map hints)
- **After**: 113 issues (3 medium, 110 low)

The 3 remaining medium issues are intentional AST traversal patterns, and the 110 low issues are benchmark suggestions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,39 @@ for _, other := range others {
// perf:ignore-end
```

## Dogfooding: goperf on Itself

We run `goperf` on its own codebase. Here's what happened:

```
$ goperf ./...
╭───────────────────────────────────────────────────────────────────╮
│ PERF-AUDIT: 147 issues found (36 medium, 111 low) │
╰───────────────────────────────────────────────────────────────────╯
```

**We fixed all 34 actionable issues:**

| Issue Type | Count | Fix Applied |
|------------|-------|-------------|
| Unpreallocated slices | 31 | `make([]T, 0, N)` with capacity hints |
| String concat in loops | 2 | `strings.Builder` |
| Map without size hint | 1 | `make(map[K]V, size)` |

**After fixes:**
```
$ goperf ./...
╭───────────────────────────────────────────────────────────────────╮
│ PERF-AUDIT: 113 issues found (3 medium, 110 low) │
╰───────────────────────────────────────────────────────────────────╯
```

The remaining 113 issues are:
- **3 medium**: Nested loops for AST traversal (intentional, not O(n²) on data)
- **110 low**: "Consider adding benchmarks" suggestions

This demonstrates that `goperf` finds real issues - including in itself - and that fixing them is straightforward.

## Contributing

Contributions welcome! Areas we'd love help with:
Expand Down
Loading