Skip to content

feat: Performance Benchmarks für Sync & Export mit Regression Detection #351

@paulefl

Description

@paulefl

Beschreibung

Implementiere Benchmarks für kritische Code-Paths (Sync-Engine, Mermaid-Export) mit Regression Detection in CI. Ermöglicht Performance-Tracking über Releases hinweg.

Motivation:

  • Go Tool: go test -bench ist built-in, keine Dependencies
  • Verhindert Performance-Degradation
  • Baseline für Performance-SLOs
  • Data-driven optimization decisions

Implementation Plan

Phase 1: Benchmark-Suite erstellen (2h)

  1. internal/sync/benchmark_test.go

    • BenchmarkSyncSmallModel (100 elements)
    • BenchmarkSyncLargeModel (5000 elements)
    • BenchmarkDetectChanges
    • BenchmarkApplyForward
    • BenchmarkApplyReverse
  2. internal/diagram/benchmark_test.go

    • BenchmarkExportMermaid (10 views)
    • BenchmarkExportMermaid (100 views)
    • BenchmarkWrapDiagramsInMarkdown
  3. internal/model/benchmark_test.go

    • BenchmarkLoad (JSONC parsing)
    • BenchmarkFlattenElements
    • BenchmarkResolveView
    • BenchmarkValidate

Deliverable: benchmarks run locally go test -bench=./internal/sync/


Phase 2: CI Integration & Baselines (1.5h)

  1. .github/workflows/benchmark.yml

    • Run benchmarks on every PR
    • Store results in benchmarks/ directory
    • Generate summary comment on PR
  2. Create baseline results

    go test -bench=. -benchmem ./internal/sync/ > benchmarks/main.txt
  3. Add benchstat tool

    • Compare PR results vs main
    • Flag >5% regressions

Deliverable: CI workflow, baseline file in repo


Phase 3: Documentation & SLOs (1h)

  1. BENCHMARKS.md

    • Expected runtimes per benchmark
    • Hardware specs (CPU, RAM used for baseline)
    • How to run locally
    • Regression interpretation
  2. Performance SLOs

    Sync 1000 elements: <500ms
    Sync 10000 elements: <5s
    Export 100 views: <2s
    Model.Load 50MB: <1s
    

Deliverable: BENCHMARKS.md, SLO document


Akzeptanzkriterien

  • ✅ Mindestens 10 Benchmarks implementiert (sync, diagram, model)
  • ✅ Benchmarks laufen in CI auf jedem PR
  • ✅ Baseline-Ergebnisse gespeichert (benchmarks/main.txt)
  • ✅ Regression-Detection: >5% Abweichung flagged
  • ✅ Dokumentation: How-to-run, SLOs, expected values
  • ✅ All benchmarks stable (<5% variance in 3 runs)

Aufwand: 3-4 Stunden

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions