Performance Baseline (Scale Version, Phase D)
This document is the reproducible baseline kit for:
- dataset size ramp (10^5 class)
- API latency percentiles (write/recall p50/p95/p99)
- worker throughput
- planner/index sanity (
EXPLAIN ANALYZE)
1) Preconditions
bash
cd /Users/lucio/Desktop/Aionis
set -a; source .env; set +a
make db-migrateRun API and worker in separate terminals:
bash
npm run dev
npm run job:outbox-worker2) Index Checklist (Must Exist)
Required minimum:
memory_nodes_embedding_hnsw_idxmemory_nodes_embedding_ready_hot_warm_hnsw_idxmemory_edges_scope_src_type_idxmemory_edges_scope_dst_type_idx
Quick check:
bash
psql "$DATABASE_URL" -c "\d memory_nodes" | rg -n "hnsw|embedding"
psql "$DATABASE_URL" -c "\d memory_edges" | rg -n "scope_src_type|scope_dst_type"3) Seed Synthetic Dataset
Preferred (tenant-aware, commit-tracked job):
bash
npm run job:perf-seed -- \
--scope perf \
--tenant-id default \
--src-scope default \
--src-tenant-id default \
--events 100000 \
--topics 1000 \
--resetAlternative SQL seed (legacy path):
bash
psql "$DATABASE_URL" -v src_scope='default' -v scope='perf' -v n='50000' -f /Users/lucio/Desktop/Aionis/sql/seed_perf_dataset.sql4) API Latency Benchmark
bash
npm run job:perf-benchmark -- \
--base-url "http://localhost:${PORT:-3001}" \
--scope perf \
--tenant-id default \
--mode all \
--warmup 20 \
--recall-requests 300 \
--recall-concurrency 12 \
--write-requests 120 \
--write-concurrency 4Output fields:
cases[].latency_ms.p50/p95/p99cases[].rpscases[].failedcases[].by_statuscompression.summary.compression_ratio.mean(when--compression-check=true)compression.summary.items_retain_ratio.meancompression.summary.citations_retain_ratio.mean
One-command matrix (seed + bench + explain + report):
bash
npm run perf:phase-d-matrixCurrent defaults (recommended):
SCOPE_STRATEGY=isolated(each run uses unique scope)RESET_MODE=auto(isolated scopes avoid destructive reset)RESET_IMPL=scope_purge+RESET_PURGE_MODE=partition(reset path prefers partition truncate)RESET_PURGE_FAIL_ON_DELETE=true(fail fast if reset falls back to delete)recall_slo/write_slodisable heavy explain + worker benchmark by default for faster, cleaner SLO signals
When you must reset a fixed scope, use offline-window guard:
bash
SCOPE_STRATEGY=fixed RESET_MODE=always PERF_OFFLINE_WINDOW=true \
RESET_IMPL=scope_purge RESET_PURGE_MODE=partition \
npm run perf:phase-d-matrixTemporary compatibility mode (allows fallback delete):
bash
SCOPE_STRATEGY=fixed RESET_MODE=always PERF_OFFLINE_WINDOW=true \
RESET_IMPL=scope_purge RESET_PURGE_MODE=auto RESET_PURGE_ALLOW_FALLBACK_DELETE=true \
RESET_PURGE_FAIL_ON_DELETE=false npm run perf:phase-d-matrixSLO profile variants:
bash
# 1) Recall SLO
PERF_PROFILE=recall_slo SCALES=100000 npm run perf:phase-d-matrix
# 2) Write SLO
PERF_PROFILE=write_slo SCALES=100000 npm run perf:phase-d-matrix
# 3) Worker SLO (auto build embed backlog before worker benchmark)
PERF_PROFILE=worker_slo SCALES=100000 npm run perf:phase-d-matrix
# 4) Compression SLO (focus on compaction KPI, non-blocking by default in core gate)
PERF_PROFILE=compression_slo SCALES=100000 npm run perf:phase-d-matrixArtifacts default path:
/Users/lucio/Desktop/Aionis/artifacts/perf/<timestamp>/- includes
seed_*.json,benchmark_*.json,benchmark_adapt_*.json,explain_*.txt,worker_baseline.json,PERFORMANCE_REPORT_V1.md
Profile behavior summary:
balanced(default): mixed recall+write benchmark.recall_slo: benchmark moderecall, tuned concurrency + adaptive pacing (429-aware) for recall stability checks; skips explain/worker benchmark unless overridden.write_slo: benchmark modewrite, conservative write concurrency + adaptive pacing to reduce429distortion; skips explain/worker benchmark unless overridden.worker_slo: lightweight recall benchmark + extra write pass withembed_on_write=trueto create outbox backlog before worker throughput measurement.compression_slo: recall benchmark with compression KPI sampling (--compression-check=true) for token-budget compaction quality tracking.
5) Worker Throughput Benchmark
bash
npm run job:perf-worker-benchmark -- --scope default --iterations 8Output fields:
totals.throughput_processed_per_sectotals.processedoutbox_before/outbox_afterper_iteration[]
6) Planner Baseline (EXPLAIN ANALYZE)
bash
psql "$DATABASE_URL" -v scope='perf' -v lim='30' -f /Users/lucio/Desktop/Aionis/sql/explain_baseline.sqlForce-index sanity check:
bash
psql "$DATABASE_URL" -v scope='perf' -v lim='30' -v force_index=1 -f /Users/lucio/Desktop/Aionis/sql/explain_baseline.sqlExpected:
- Stage-1 should use embedding index path when dataset is large enough.
- Stage-2 neighborhood query should stay within configured budgets.
7) Performance Report Template (Fill Per Run)
Template file:
/Users/lucio/Desktop/Aionis/docs/PERFORMANCE_REPORT_V1_TEMPLATE.md
Run Metadata
- Date:
- Branch/commit:
- Host spec:
- PostgreSQL version:
- Scope/tenant:
- Dataset size:
API Latency
- Recall p50/p95/p99:
- Write p50/p95/p99:
- Recall RPS:
- Write RPS:
- Error rate:
Worker Throughput
- Processed/sec:
- Claimed total:
- Failed marked:
- Outbox backlog delta:
Planner Notes
- Stage-1 plan key lines:
- Stage-2 plan key lines:
- Total execution time:
Conclusion
- Pass/Fail against SLO:
- Primary bottleneck:
- Next tuning action:
8) Suggested SLO Starter
- Recall p95
< 300ms(local 10^5 scope baseline target) - Write p95
< 500ms(auto_embed=false benchmark profile) - Worker throughput
> 50 jobs/son local dev hardware (batch/once mode dependent)
Verification Stamp
- Last reviewed:
2026-02-16 - Verification commands:
npm run docs:checknpm run job:perf-seed -- --scope perf --events 50000 --topics 500 --resetnpm run job:perf-benchmark -- --scope perf --mode allnpm run job:perf-worker-benchmark -- --scope default --iterations 5psql \"$DATABASE_URL\" -v scope='perf' -v lim='30' -f /Users/lucio/Desktop/Aionis/sql/explain_baseline.sql