Skip to content

feat(bench): add benchmark infrastructure and optimization targets#569

Merged
wizzomafizzo merged 5 commits intomainfrom
benchmarks
Mar 24, 2026
Merged

feat(bench): add benchmark infrastructure and optimization targets#569
wizzomafizzo merged 5 commits intomainfrom
benchmarks

Conversation

@wizzomafizzo
Copy link
Copy Markdown
Member

Summary

  • Benchmarks for all hot paths: slug search cache, fuzzy matching, slug generation, filename parsing, NDEF parsing, config, mappings, advargs
  • Taskfile tasks: bench, bench-db, bench-baseline, bench-compare
  • Performance targets in docs/optimization-targets.md
  • Agent prompts for security review, dependency audit, and optimization scanning
  • AGENTS.md updates for benchmark conventions and background agent guardrails

Add comprehensive benchmarks across the critical path (slug search cache,
fuzzy matching, slug generation, filename parsing, NDEF parsing, config,
mappings, advargs). Add Taskfile tasks for bench workflow (bench, bench-db,
bench-baseline, bench-compare). Add optimization target documentation and
background agent prompts for security review, dependency audit, and
optimization scanning. Add AGENTS.md sections for benchmarks and background
agent mode.
@sentry
Copy link
Copy Markdown

sentry Bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/database/mediadb/slug_search_cache.go 71.42% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…marks

- Batch inserter benchmarks (insert, flush cost, commit cost) with real SQLite
- Slug search cache build from real DB (10k, 50k titles)
- Title resolution benchmarks (cache hit, exact match, fuzzy fallback)
- Scan-to-launch pipeline benchmarks (exact match, direct path, with mapping)
- Shared BuildBenchFilenames helper in pkg/testing/fixtures
- Refactor NewInMemoryMediaDB to accept testing.TB for benchmark use
- Remove stale fuzz commands for deleted zapscript/parser package
- Fix bench tasks: add -run='^$', filter baseline output for benchstat
Add cross-compile + SSH pipeline for running benchmarks on real MiSTer
hardware (Cortex-A9). Reduce benchmark sizes to fit MiSTer's 492MB RAM.
Suppress zerolog output during benchmarks to prevent output corruption.
Generate x86 and MiSTer baseline files.
Add Size() method to SlugSearchCache for deterministic memory
measurement — replaces broken HeapAlloc delta that reported ~0 MB.
Add runtime.KeepAlive to FlushScanStateMaps benchmark to prevent
compiler dead-code elimination (was 78x too fast on x86).

Update optimization targets with MiSTer multiplier bands, resolution
cache optimization opportunity, and revised targets based on production
measurements. Regenerate both baselines.
…rkflow

Rewrite optimization-scan.md from generic 20-line prompt to full
autoresearch-style experiment loop with keep/discard logic, MiSTer
prediction via multiplier bands, and scope constraints.

Add 4 target-specific prompts with exact file/function references,
benchmark commands, x86 CI thresholds, and algorithmic ideas:
- optimize-slug-search.md (#1: Search() linear scan, target 2.9ms x86)
- optimize-fuzzy-matching.md (#2: worst-case full scan, target 2.9ms x86)
- optimize-indexing.md (#3: pipeline 32s/10k, target 21s/10k on MiSTer)
- optimize-memory.md (#4: 101MB RSS investigation, target 50MB)
@wizzomafizzo wizzomafizzo merged commit 2dc4f42 into main Mar 24, 2026
10 checks passed
@wizzomafizzo wizzomafizzo deleted the benchmarks branch March 24, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant