yams/tests/benchmarks/xplan
Trevon ae15bf317a
perf(ingest): harden daemon batching and shutdown (#58)
* fix(daemon): harden model state ownership

Keep ModelPoolConfig single-defined and serialize telemetry snapshots to avoid ODR drift and torn concurrent reads.

* refactor(daemon): consolidate ingest pollers

Require the wake-timer contract so every post-ingest stage shares one event-driven poller configuration.

* refactor(daemon): unify repair execution

Share admission, operation ordering, cancellation, progress, and result aggregation between synchronous and asynchronous repair paths.

* refactor(daemon): unify runtime tuning

Resolve startup and reload settings through one typed path so parsing, precedence, and range validation cannot drift.

* refactor(daemon)!: remove dead IPC surfaces

Delete unreferenced framing, cancellation, and compatibility paths while keeping the active streaming protocol intact.

BREAKING CHANGE: callers using connectAsync or legacy MessageFramer and FrameReader helpers must migrate to connect, frame_message_into, feed, and get_frame.

* refactor(daemon): hide test hooks

Preserve test-library linkage without exposing daemon-only probes through production headers or external symbols.

* fix(daemon): avoid replaying successful adds

A fresh-connection transport retry reuses the response handler. Clear its stale EOF error when the retry returns a valid add response so the outer retry loop does not enqueue the document again.

* bench(ingest): enforce lossless pipeline runs

Separate admission, storage, drain, enrichment, and searchability timing. Decision-grade plans now reject drops, duplicate processing, incomplete pipelines, and experiment identity drift.

* bench(search): expose cold seed ingest timings

Pair generalized-memory quality arms with admission, storage, drain, searchability, and enrichment timing from their shared cold seed. Keep the observation distinct from repeated throughput measurements.

* perf(ingest): batch deferred content indexing

Directory ingestion already schedules content work through post-ingest. Avoid duplicate inline indexing and coalesce normal-priority trickles within a bounded window.

* feat(metadata): expose insert writer metrics

Separate queue, batch-apply, and transaction time so ingestion runs can attribute connection pressure without changing write semantics.

* fix(daemon): retry transient refused connects

The daemon socket can be bound before its listener is ready during startup. Reuse the existing bounded retry budget for that refusal window.

* bench(ingest): attribute submission path costs

Decision-grade runs need stable coalescing identity and separate queue, apply, transaction, and estimated connection-wait costs.

* perf(ingest): batch durable document storage

Commit chunks, manifests, references, and metadata in bounded batches while preserving publication only after durable reference success.

* perf(ingest): coalesce bulk post-processing

Use a 16-item bulk cap while keeping latency-sensitive daemon ingestion on the existing four-item priority quota.

* bench(ingest): record post-ingest batch size

Include the effective cap in metrics and experiment identity so runs with different batching policies cannot be compared as one system.

* perf(ingest): batch queued storage waves

Preserve single-document fallback semantics and execute inline when the coordinator has one worker to avoid self-deadlock.

* perf(ingest): route bulk enrichment batches

Keep quota-sized interactive groups on the RPC lane while sending larger lossless groups through bounded coalescing.

* test(daemon): initialize task fixtures

* perf(ingest): batch post-ingest dispatch

* perf(ingest): widen directory storage waves

Borrow from a full wave when one document would otherwise fall through to single-document storage.

* perf(storage): bound batch writer fanout

Reuse a fixed worker set so batch size no longer creates one thread and payload copy per object.

* perf(ingest): align storage batch drains

Dispatch one configured batch through storage so intermediate waves do not fragment downstream metadata work.

* fix(ingest): commit metadata state atomically

Fold first-version, extracted-title, and embedding-completion state
into existing transactions.

Read committed extraction state so duplicate-content tasks cannot
double-count corpus counters.

* bench(ingest): measure production submission

Drive pipelined files through DocumentIngestionService.
Export dispatch, fingerprint, and enqueue costs through xplan.

* fix(xplan): preserve native failures

Report child signals and bounded stderr before readiness checks so
assertions are not masked as missing traces.

* fix(daemon): preserve embedding success hashes

* fix(daemon): serialize pooled socket shutdown

* fix(daemon): harden batch publication shutdown

* fix(storage): use compat jthread shim

* fix(daemon): avoid poller template shadowing

* fix(search): keep vector pipeline test enabled

* fix: harden shutdown and fallback paths

Demote expected shutdown SQL interruptions, ignore readonly FTS integrity noise, avoid stopped-executor socket hangs, and preserve metadata writer fallback outcomes.
2026-07-17 07:04:30 -04:00
..
plans perf(ingest): harden daemon batching and shutdown (#58) 2026-07-17 07:04:30 -04:00
schema feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
workers perf(ingest): harden daemon batching and shutdown (#58) 2026-07-17 07:04:30 -04:00
__init__.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
analyze_query_class.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
artifacts.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
model.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
README.md feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
report.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
runner.py perf(ingest): harden daemon batching and shutdown (#58) 2026-07-17 07:04:30 -04:00
summarize.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
test_xplan_contracts.py perf(ingest): harden daemon batching and shutdown (#58) 2026-07-17 07:04:30 -04:00
validate.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00

xplan (engineering)

Unified multi-arm experiment runner for daemon KPI work. Not a product surface.

Commands

python3 tests/benchmarks/xplan/runner.py self-test
python3 tests/benchmarks/xplan/runner.py list-plans
python3 tests/benchmarks/xplan/runner.py list-workers

# BEIR corpora for quality/topology plans (auto-fetched on first run too)
python3 tests/benchmarks/xplan/runner.py download-beir            # scifact + nfcorpus
python3 tests/benchmarks/xplan/runner.py download-beir scifact
python3 tests/benchmarks/xplan/runner.py download-beir --list

# Run a plan (writes artifacts under build/benchmarks/)
python3 tests/benchmarks/xplan/runner.py run <plan> --build-dir build/release
python3 tests/benchmarks/xplan/runner.py run <plan> --dry-run
python3 tests/benchmarks/xplan/runner.py run <plan> --arm baseline --arm no_kg

# Regenerate docs for an existing artifact directory
python3 tests/benchmarks/xplan/runner.py report build/benchmarks/<plan>/<stamp>

# Compare two stamps
python3 tests/benchmarks/xplan/runner.py compare \
  build/benchmarks/ingest_pipeline/<stampA> \
  build/benchmarks/ingest_pipeline/<stampB>

Generated report files (per run)

File Contents
REPORT.md Full engineering report: host/git, primary + all metrics, factors, per-arm detail
ablation.md Baseline vs other arms, relative deltas, ranking hints
metrics.csv Flat table for spreadsheets
report.json Machine-readable full report
summary.md / summary.json Compact overview
arms/<arm>/metrics.json Per-arm KPIs + ablation attributes

All under build/benchmarks/<plan>/<stamp>/ (gitignored).

Layout

tests/benchmarks/xplan/
  runner.py          # CLI
  plans/*.json       # experiment definitions
  workers/           # measurement adapters + ablation.py
  report.py          # REPORT.md / ablation.md / csv
  summarize.py       # compact summary + report hook
  schema/            # plan schema

Ablation

workers/ablation.py maps plan factors → env (one-factor-off):

  • Search components: YAMS_SEARCH_*_WEIGHT=0 + YAMS_ENABLE_ENV_OVERRIDES=1
  • Ingest: YAMS_BENCH_DISABLE_KG, YAMS_DISABLE_VECTORS, GLiNER
  • Topology mode / expansion presets (full64, medoid64, cap8, cap2) in retrieval_quality

Plans (engineering)

Plan Focus
search_component_ablation / subsystem_overhead Search engine component one-factor-off (BEIR scifact)
leg_stage_ablation / simeon_rerank* Search pipeline / rerank arms
ingest_pipeline Ingest kg/vectors/gliner (synthetic — throughput, not ranking)
retrieval_load / repair_ability / ops_timeline / daemon_ops_core Daemon KPIs 2–5
read_write_pressure Equal-budget write-heavy/balanced/read-heavy/read-only daemon load; per-op latency, DB pools, WriteCoordinator pressure, WAL growth, drain, and recovery (repeats=3)
topology_purity_validate / topology_routing_budget_ablation Topology construction purity and routed-vs-global ANN budget gate (repeats=3)
search_generalized_memory_topology_gate SciFact + NF-Corpus in one index; per-source quality, cross-source interference, and topology-vs-global cost (repeats=3)
search_simeon_ann_attribution_multicorp Mixed-corpus text/current-PQ/exact-vec0 attribution over identical Simeon embeddings (repeats=3)
plans/archive/* Superseded plans (historical only)

Agent measurement loop and plan selection: repo AGENTS.md (Benchmarks & Experiments).

Corpora

Kind Used by Notes
BEIR scifact (default for quality) search_component_*, topology_*, simeon_rerank*, leg_stage_* ~/.cache/yams/benchmarks/scifact; auto-download on run
BEIR nfcorpus optional plan override dataset=nfcorpus same cache layout
Mixed BEIR memory search_generalized_memory_topology_gate one daemon/index containing namespaced SciFact + NF-Corpus documents and queries
synthetic ingest/load/ops throughput only not for ranking ablations — opt-in via "dataset": "synthetic"

Default quality params: dataset=scifact, corpus_size=2000, num_queries=50.

Plans with separate SciFact and NF-Corpus arms test transfer between isolated indexes; they do not model generalized memory. A retrieval-quality plan can set datasets to two or more BEIR names to materialize one content-deduplicated local-manifest for the entire run. The worker namespaces document/query IDs, remaps duplicate-content qrels, and reports per-source MRR/recall plus mixed_cross_source_result_rate and mixed_cross_source_top1_rate from the shared ranking. The benchmark also exports topology_clusters.json and derives mixed_cluster_overlap.json, which shows source counts, entropy, and purity for every cluster. Aggregate metrics distinguish the fraction of cross-source clusters from the fraction of documents exposed to those clusters; content duplicated across corpora is reported separately and excluded from partition purity.

For state-sensitive search ablations, shared_warm_cache primes one immutable YAMS store and clones it into each measured arm/repeat. This fixes corpus, vector index, tuner state, and persisted topology without letting one workload mutate the next workload's input. Topology plans can also set require_topology_construction_identity=true; the worker pins the first construction fingerprint and fails on within-workload, cross-repeat, or cross-arm drift. Do not point multiple measured arms at one live warm directory: that preserves topology but carries mutable query/tuner state forward.

Evaluate ingestion changes in two lanes at the same code revision. Use search_generalized_memory_topology_gate after the index settles for mixed-memory quality and route purity. Use retrieval_load for concurrent adds/searches through the daemon; it reports post-ingest backlog plus WriteCoordinator queue depth, in-flight work, apply time, queue wait, and excess queue wait. Do not combine these into one score: promote an ingestion change only when it preserves the per-source quality floor and improves or holds the read-under-write pressure KPIs.

Use read_write_pressure when the question is contention rather than search-component attribution. Its arms execute the same operation budget per client, vary only the read/write mix, and subtract a post-warmup infrastructure baseline from cumulative queue/WAL counters. Point-in-time queue depth and the workload high-water delta are both retained so short bursts are not hidden by sampling. Set harness-only YAMS_BENCH_CORPUS_SEED_DIR to a frozen YAMS data directory to give every arm/repeat an isolated copy-on-write corpus; YAMS_BENCH_SEARCH_QUERY can select a representative symbol or concept. The source directory is never opened by the daemon and remains unchanged.

Rules

  • No new multi-arm shell scripts. Wrappers under scripts/ only.
  • Prefer typed config for product knobs; YAMS_BENCH_* is harness-only.
  • Do not rank search levers on synthetic — BEIR only (or another labeled hard corpus).
  • Topology claims need debug.jsonl counters / certificates.
  • Multi-client plans need a Catch2-enabled builddir.
  • Published numbers: docs/benchmarks/README.md (default system only).

Known infrastructure debt

  • yams graph --explore can fail with a local index SQL logic error for valid readiness symbols (observed on SearchEngineManager::getSnapshot / rebuildNow). The fallback is a targeted local read after YAMS retrieval identifies the files. Follow-up: capture yams doctor diagnostics, verify graph/index schema integrity, and add a regression fixture before changing graph-query behavior.