From b6ea72fa3a2074574d0963277862a0fe433b858e Mon Sep 17 00:00:00 2001 From: Corey Schuman Date: Mon, 5 Jan 2026 22:10:35 -0500 Subject: [PATCH] docs: add dogfooding results and changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit README.md: - Add "Dogfooding: goperf on Itself" section showing before/after results - Documents 147 → 113 issues after fixing 34 actionable problems - Shows the specific fixes applied (preallocation, strings.Builder, map hints) CHANGELOG.md: - Create initial changelog for v0.1.0 - Document all 9 rule categories and features - Include dogfooding results as validation --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ README.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..07fc900 --- /dev/null +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index a2f1ca3..48091e9 100644 --- a/README.md +++ b/README.md @@ -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: