arborist/bench/run.sh
russell@unturf.com 8d6961fcc1
aborist/arborist
modified:   .gitlab-ci.yml
	modified:   bench/qa_questions.txt
	modified:   bench/qa_sweep.py
	modified:   bench/run.sh
	modified:   docs/TICKETS.md
	modified:   docs/_source/README.md
	modified:   docs/_source/_ext/makefile_targets.py
	modified:   docs/_source/api/cli.rst
	modified:   docs/_source/api/distill.rst
	modified:   docs/_source/api/mesh.rst
	modified:   docs/_source/api/qa.rst
	modified:   docs/_source/api/retrieval.rst
	modified:   docs/_source/api/storage.rst
	modified:   docs/_source/api/substrate.rst
	modified:   docs/_source/concepts.rst
	modified:   docs/_source/conf.py
	modified:   docs/_source/cookbook.rst
	modified:   docs/_source/index.rst
	modified:   docs/_source/license.rst
	modified:   docs/_source/quickstart.rst
	modified:   docs/bench-maxing.md
	modified:   docs/benchmarks.md
	modified:   docs/cti-architecture.md
	modified:   docs/diagrams/aborist-modules.dot
	modified:   docs/diagrams/aborist-modules.svg
	modified:   docs/diagrams/mesh-data-flow.dot
	modified:   docs/diagrams/mesh-epoch-lifecycle.dot
	modified:   docs/diagrams/mesh-epoch-lifecycle.svg
	modified:   docs/diagrams/mesh-group-decisions.dot
	modified:   docs/diagrams/mesh-group-decisions.svg
	modified:   docs/diagrams/mesh-identity-stack.dot
	modified:   docs/diagrams/mesh-secret-envelope.dot
	modified:   docs/mesh.md
	modified:   docs/qa-modes-bench.md
	modified:   docs/seven-point-program.md
	modified:   docs/tickets/ticket-000001-retrieval-keywords-audit-gap.md
	modified:   docs/tickets/ticket-000002-reference-frame-polarity-contract.md
	modified:   docs/tickets/ticket-000003-anchor-class-warrant.md
	modified:   docs/tickets/ticket-000005-label-ladder-migration.md
	modified:   docs/tickets/ticket-000006-bench-emergent-findings.md
	modified:   docs/tickets/ticket-000007-query-layer-hyphen-fold.md
	modified:   docs/tickets/ticket-000008-broad-quantifier-preflight-guard.md
	modified:   docs/tickets/ticket-000009-quantifier-preflight-dag-binding.md
	modified:   docs/tickets/ticket-000010-metacognition-preflight-guard.md
	modified:   docs/tickets/ticket-000011-soft-preflight-hint-sidecar.md
	modified:   scripts/backfill_concepts.py
	modified:   scripts/bench_emergent.py
	modified:   tests/crawler/test_async_web_fetcher.py
	modified:   tests/crawler/test_bridge.py
	modified:   tests/crawler/test_web_fetch.py
	modified:   tests/test_bench_qa_sweep.py
	modified:   tests/test_burn.py
	modified:   tests/test_burn_doc.py
	modified:   tests/test_claim_lattice.py
	modified:   tests/test_cli_render.py
	modified:   tests/test_compress.py
	modified:   tests/test_concepts.py
	modified:   tests/test_dag.py
	modified:   tests/test_directives.py
	modified:   tests/test_distill.py
	modified:   tests/test_distill_recursive.py
	modified:   tests/test_evict.py
	modified:   tests/test_frame.py
	modified:   tests/test_grok_source.py
	modified:   tests/test_html_source.py
	modified:   tests/test_ingest.py
	modified:   tests/test_inspect.py
	modified:   tests/test_journal.py
	modified:   tests/test_keys.py
	modified:   tests/test_llm_context_base.py
	modified:   tests/test_merkle.py
	modified:   tests/test_mesh.py
	modified:   tests/test_mesh_aead.py
	modified:   tests/test_mesh_chain.py
	modified:   tests/test_mesh_cli.py
	modified:   tests/test_mesh_cli_pull.py
	modified:   tests/test_mesh_wire.py
	modified:   tests/test_mesh_wire_e2e.py
	modified:   tests/test_metacognition.py
	modified:   tests/test_migration_audit_mode.py
	modified:   tests/test_providence_source.py
	modified:   tests/test_qa.py
	modified:   tests/test_qa_quality_live.py
	modified:   tests/test_quantifier_caps.py
	modified:   tests/test_quantifier_classifier.py
	modified:   tests/test_quantifier_phase4.py
	modified:   tests/test_quantifier_reminder.py
	modified:   tests/test_query.py
	modified:   tests/test_reclassify.py
	modified:   tests/test_repair.py
	modified:   tests/test_resume.py
	modified:   tests/test_snapshot.py
	modified:   tests/test_soft_preflight.py
	modified:   tests/test_tfidf.py
	modified:   tests/test_vcs_source.py
	modified:   tests/test_verify.py
	modified:   tests/test_verify_json.py
	modified:   tests/test_versioned_ingest.py
	modified:   tests/test_warrant.py
	modified:   tests/test_wikipedia_old.py
	modified:   tests/test_wikipedia_xml.py
	modified:   tests/test_wikitext.py
2026-05-07 09:31:49 -04:00

107 lines
3.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Reproducible ETL throughput benchmark.
#
# Three configurations against a fixed BENCH_DOCS slice of the Wikipedia
# 2003-05-16 cur dump:
#
# serial single process, single SQLite (Phase 1a)
# parallel-shared N shards, one shared SQLite (Phase 1b — WAL serialized)
# attached N shards, per-shard SQLite (Phase 2 — true parallel writes)
#
# Output: per-config wall, throughput (docs/s), and a one-line summary table.
set -uo pipefail
BENCH_DOCS=${1:-5000}
BENCH_DIR=${BENCH_DIR:-/tmp/arborist-bench}
SHARDS=${SHARDS:-4}
DUMP=${DUMP:-data/20030516_cur_tablesql.bz2}
ARBORIST=${ARBORIST:-.venv/bin/arborist}
mkdir -p "$BENCH_DIR"
if [[ ! -f "$DUMP" ]]; then
echo "missing dump $DUMP — run 'make fetch-cur' first" >&2
exit 2
fi
run_silent() {
# $1 = label (writes wall time in seconds to stdout)
local start end
start=$(date +%s.%N)
"$@" >/dev/null 2>&1
end=$(date +%s.%N)
echo "$end - $start" | bc -l
}
# Each row will be: label,wall_s,docs/s
declare -a results
bench_serial() {
local db=$BENCH_DIR/serial.db
rm -f "$db" "$db-"*
local wall
wall=$(run_silent "$ARBORIST" --db "$db" ingest --quiet \
--source wikipedia_cur --path "$DUMP" --limit "$BENCH_DOCS")
local docs
docs=$(sqlite3 "$db" "SELECT COUNT(*) FROM documents")
printf "serial,%s,%s\n" "$wall" "$docs"
}
bench_parallel_shared() {
local db=$BENCH_DIR/shared.db
rm -f "$db" "$db-"*
local per=$((BENCH_DOCS / SHARDS))
local start end wall
start=$(date +%s.%N)
for i in $(seq 0 $((SHARDS - 1))); do
"$ARBORIST" --db "$db" ingest --quiet \
--source wikipedia_cur --path "$DUMP" \
--shard "$i/$SHARDS" --limit "$per" >/dev/null 2>&1 &
done
wait
end=$(date +%s.%N)
wall=$(echo "$end - $start" | bc -l)
local docs
docs=$(sqlite3 "$db" "SELECT COUNT(*) FROM documents")
printf "parallel-shared,%s,%s\n" "$wall" "$docs"
}
bench_attached() {
local dir=$BENCH_DIR/attached
rm -rf "$dir"
mkdir -p "$dir"
local per=$((BENCH_DOCS / SHARDS))
local start end wall
start=$(date +%s.%N)
for i in $(seq 0 $((SHARDS - 1))); do
"$ARBORIST" ingest --quiet \
--source wikipedia_cur --path "$DUMP" \
--shards-dir "$dir" --shard "$i/$SHARDS" --limit "$per" >/dev/null 2>&1 &
done
wait
end=$(date +%s.%N)
wall=$(echo "$end - $start" | bc -l)
local docs
docs=$("$ARBORIST" --shards-dir "$dir" stats 2>/dev/null \
| python3 -c "import json,sys; print(json.load(sys.stdin)['documents_total'])")
printf "attached,%s,%s\n" "$wall" "$docs"
}
echo "=== arborist ETL benchmark — $BENCH_DOCS docs target, $SHARDS shards ==="
echo
results+=("$(bench_serial)")
results+=("$(bench_parallel_shared)")
results+=("$(bench_attached)")
# Pretty table.
printf " %-18s %10s %10s %12s\n" "config" "wall_s" "docs" "docs/s"
printf " %-18s %10s %10s %12s\n" "------" "------" "----" "------"
for row in "${results[@]}"; do
IFS=',' read -r label wall docs <<<"$row"
rate=$(echo "scale=1; $docs / $wall" | bc -l)
printf " %-18s %10.2f %10s %12s\n" "$label" "$wall" "$docs" "$rate"
done
echo
echo " (raw CSV: $BENCH_DIR/results.csv)"
{ printf "config,wall_s,docs\n"; printf "%s\n" "${results[@]}"; } > "$BENCH_DIR/results.csv"