Files
Sprachmittler/docs/PERFORMANCE.md
T
schihei 0ab5ae78bf feat(m7-m8): evaluation harness, privacy self-test, localisation and release
M7: corpus manifest loader/validation, chrF/BLEU/token/numeric metrics, raw-output and report.md/report.json writer, and sprachmittler-cli languages/detect/eval. A synthetic 4-segment run with the 7B validated the harness; the private-corpus and 1.8B evaluation and the default-model ADR remain open.

M8: privacy-check root fixture + seeded self-test wired into make verify; English/German localisation for the app shell; end-user USER_GUIDE; release.sh (unsigned archive, Developer ID sign, notarise/staple, DMG, --dry-run); idle CPU/memory and warm 7B measurements in PERFORMANCE.

Docs: PROGRESS M7–M8, MODEL_EVALUATION results log/gate status, PERFORMANCE measurements, TESTING evaluation cases, ADR-008 status. Compatibility/VoiceOver/notarisation gates remain manual.

Verified: make verify green (format, strict lint, privacy self-test, Debug+Release signatures, 227 package tests); CLI languages/detect/eval run; release dry-run.
2026-11-26 14:16:21 +01:00

4.5 KiB
Raw Blame History

Performance

Status: Draft v1.0. Targets are validated on named hardware. Translation speed depends on the model and the Mac; it is measured, not promised.

1. Reference measurements

Date Hardware macOS Ollama Model Prompt tokens Output tokens First token Total Eval rate Resident
2026-11-26 M5 Pro, 48 GB 27.2.1 0.40.18 7B Q4_K_M 178 (owner: 177 cached) 255 (owner) not recorded 5.97 s (owner) 43.07 tok/s —
2026-11-26 M5 Pro, 48 GB 27.2.1 0.40.18 7B Q4_K_M 178 246 not recorded 6.52 s 44.6 tok/s 6.49 GB

The owner's run and the verification run used the same canonical prompt and the same source paragraph (the Hy-MT3 figure caption). The difference is normal sampling variance.

2. Budgets

Metric Budget How measured
Second copy → session start ≤ 150 ms signpost capture
Panel visible ≤ 250 ms after trigger signpost panel
First translation token (warm 7B) ≤ 1.5 s signpost firstToken
250 output tokens (warm 7B) ≤ 8 s on an M-series Pro CLI bench
Copy to clipboard ≤ 100 ms signpost copy
Replace via AX ≤ 300 ms after click signpost insert
Replace via paste ≤ 700 ms including clipboard restore signpost insert
Idle CPU < 0.5% Activity Monitor / powermetrics
Idle memory (app, excluding Ollama) ≤ 90 MB footprint
Main-thread hang none > 100 ms Instruments Hangs
7B resident memory (8K context) about 6.5 GB ollama ps
1.8B resident memory about 1.6–2.0 GB ollama ps (VERIFY)

3. How to measure

make smoke                                      # fixed synthetic sentence, 7B or all Hy-MT3 tags
swift run --package-path Packages/SprachmittlerKit sprachmittler-cli \
  translate --file sample.txt --target de --model hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M --json
ollama ps                                       # resident memory and expiry
footprint -p $(pgrep -x Sprachmittler)           # app memory, excluding Ollama
  • Run cold (after keep_alive: 0 and a restart) and warm.
  • Record prompt tokens, output tokens, first-token latency and total time; the CLI JSON includes them.
  • For the panel, use os_signpost intervals and Instruments; do not estimate from wall-clock clicks.
  • For idle CPU, leave the app running with the panel closed for 5 minutes and sample Activity Monitor. The pasteboard poll is 120 ms; if idle CPU exceeds 0.5%, increase the interval to 200 ms and re-measure.

4. Model choice

  • The 7B Q4_K_M is the quality default. It needs about 6.5 GB resident plus the app and the rest of the system; on a 16 GB Mac it is usable but not comfortable alongside a browser with many tabs.
  • The 1.8B Q4_K_M is the Fast preset: about 1.35 GB download and much lower memory. Evaluate quality before recommending it broadly.
  • The 30B-A3B is not a preset. It is far above a 16 GB budget.
  • Streaming and a warm model matter more for perceived speed than a few tokens per second. Warm up on launch when the endpoint is loopback.

5. Caching

  • The prompt prefix cache is the main latency win: the owner's run reported 177/178 cached prompt tokens. Keep the prefix stable.
  • Do not add a system message, a timestamp or dynamic context to the default prompt.
  • Changing the target language changes the prefix and the cache; that is expected.
  • keep_alive: "30m" keeps the model loaded between translations. A cold load can add seconds; measure it on the target Mac and record it here.

6. App shell measurements (2026-11-26)

Metric Measurement Budget Status
Idle CPU, app only, panel closed 0.1% after 6 s < 0.5% ✅
Idle RSS, app only 86,960 KB ≈ 84.9 MB ≤ 90 MB ✅
First translation token, warm 7B (synthetic eval) 57–102 ms ≤ 1.5 s ✅
Warm segment, 7B (synthetic eval) 0.45–0.91 s 250 tokens ≤ 8 s ✅
Panel visible after a two-copy smoke panel appeared; latency not instrumented ≤ 250 ms not measured
Copy / Replace / idle hangs not instrumented budgets in §2 not measured
1.8B latency and memory model not installed budgets in §2 not measured

The synthetic eval used four short segments, one run, 7B Q4_K_M, temperature 0.7, num_ctx 8192. It validates the harness and warm 7B behavior, not the private corpus. Measure panel signposts, Copy, Replace, cold load and the 1.8B model on the target Mac before release.