Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 228 additions & 0 deletions .github/workflows/mcp-source-worker-capacity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
name: MCP source worker copy capacity

# Measures how many owner-only worker copies one Loom process keeps served: Loom from
# this checkout with its own ClickHouse and Postgres, the bundled source worker and two
# owned synthetic MCP upstreams on one GitHub-hosted runner. It records figures and
# gates on none of them; only a harness error fails the run
# (bench/source_worker_copies.py, docs/benchmarks/running.md#source-worker-copy-capacity).
on:
workflow_dispatch:
inputs:
sources:
description: Worker sources (1 to 2000)
type: number
default: 24
resources:
description: Resources each source selects (1 to 240)
type: number
default: 10
collections:
description: Collections the sources spread over, one owner each (1 to 64)
type: number
default: 4
passes:
description: Sync passes to run (1 to 100; passes times pass_interval at most 3600 s)
type: number
default: 8
pass_interval:
description: Seconds from one pass's start to the next (0 back to back; see passes)
type: number
default: 60
max_pass_seconds:
description: LOOM_KNOWLEDGE_SOURCE_SYNC_MAX_PASS_SECONDS (at least 180)
type: number
default: 180
acl_stale_seconds:
description: LOOM_KNOWLEDGE_SOURCE_ACL_STALE_SECONDS (a copy is checked every half)
type: number
default: 240
mirror_documents_per_pass:
description: LOOM_KNOWLEDGE_SOURCE_MIRROR_DOCUMENTS_PER_PASS (copies per pass)
type: number
default: 40
refresh_interval:
description: interval_seconds of the selected_refresh sources (300 to 86400)
type: number
default: 300
faults:
description: Resources per fault, of denied, unsupported, timeout, unavailable, slow
type: string
default: denied=1,unsupported=1,timeout=1,unavailable=1,slow=2
upstream_latency_ms:
description: Added latency of each upstream read
type: number
default: 20
credential_latency_ms:
description: Added latency of each worker credential lookup
type: number
default: 2
worker_concurrent:
description: The worker's read_limits.concurrent (2 to 16)
type: number
default: 8
worker_concurrent_per_org:
description: The worker's read_limits.concurrent_per_org (2 to the above)
type: number
default: 4

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

env:
PYTHON_VERSION: "3.12"
UV_VERSION: "0.12.19"

jobs:
measure:
name: Copy and check capacity on one hosted runner
runs-on: ubuntu-24.04
timeout-minutes: 90
env:
SOURCES: ${{ inputs.sources }}
RESOURCES: ${{ inputs.resources }}
COLLECTIONS: ${{ inputs.collections }}
PASSES: ${{ inputs.passes }}
PASS_INTERVAL: ${{ inputs.pass_interval }}
REFRESH_INTERVAL: ${{ inputs.refresh_interval }}
FAULTS: ${{ inputs.faults }}
UPSTREAM_LATENCY_MS: ${{ inputs.upstream_latency_ms }}
CREDENTIAL_LATENCY_MS: ${{ inputs.credential_latency_ms }}
WORKER_CONCURRENT: ${{ inputs.worker_concurrent }}
WORKER_CONCURRENT_PER_ORG: ${{ inputs.worker_concurrent_per_org }}
LOOM_ENV_FILE: ""
LOOM_CH_HOST: localhost
LOOM_CH_PORT: "8123"
LOOM_CH_USER: loom
LOOM_CH_READER_USER: loom_reader
LOOM_CH_PASSWORD: loomdev
LOOM_CH_DATABASE: loom
LOOM_CH_SECURE: "false"
LOOM_STORAGE_AUTHORITY: postgres
LOOM_PG_DSN: postgres://loom:loomdev@localhost:5432/loom
LOOM_AUTH_REQUIRED: "true"
LOOM_INSTANCE_LABEL: ci-source-worker-capacity-${{ github.run_id }}-${{ github.run_attempt }}
LOOM_BUILD_COMMIT: ${{ github.sha }}
LOOM_EMBEDDING_MODEL: fake-ngram-1024
LOOM_LLM_PROVIDER: fake
LOOM_WORKERS_PROCESS: inline
LOOM_BACKGROUND_WORKERS: auto
# The server's own sync stays off: the driver runs every pass, so it counts them.
LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED: "false"
LOOM_KNOWLEDGE_MIRRORED_SOURCES_ENABLED: "true"
LOOM_KNOWLEDGE_SOURCE_WORKER_COPIES_ENABLED: "true"
# Its least value. The server's sync is off and --pass-interval paces the passes, but a
# turn reads this to decide when a copy that keeps answering unsupported is retired.
LOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDS: "60"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass spacing ignores sync interval

Medium Severity

pass_interval is a workflow input and the driver spaces run_sync() with it, including back-to-back when it is 0. LOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDS stays hardcoded at 60, and the copy turn uses that setting for how soon an unconfirmable copy would lapse before the next pass. A non-default spacing retires or keeps copies on a cadence the harness is not actually running, so served-copy and lapse figures no longer match the pass schedule.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c8562ce. Configure here.

LOOM_KNOWLEDGE_SOURCE_SYNC_MAX_PASS_SECONDS: ${{ inputs.max_pass_seconds }}
LOOM_KNOWLEDGE_SOURCE_ACL_STALE_SECONDS: ${{ inputs.acl_stale_seconds }}
LOOM_KNOWLEDGE_SOURCE_MIRROR_DOCUMENTS_PER_PASS: ${{ inputs.mirror_documents_per_pass }}
# Quotas sized past any run, so a measurement never stops at a source count.
LOOM_KNOWLEDGE_SOURCES_MAX_PER_NAMESPACE: "2000"
LOOM_KNOWLEDGE_CONNECTED_SOURCES_MAX_PER_NAMESPACE: "2000"
LOOM_KNOWLEDGE_CONNECTED_SOURCES_MAX_PER_PERSON: "2000"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
id: python
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: false
- name: Install Loom from uv.lock
env:
PYTHON_PATH: ${{ steps.python.outputs.python-path }}
run: uv sync --locked --python "${PYTHON_PATH}" --extra dev --extra code
# The worker runs from its own wheel and lock, as the image ships it.
- name: Install the source worker
run: |
uv build --wheel source_worker --out-dir "$RUNNER_TEMP/source-worker-wheel"
uv venv "$RUNNER_TEMP/source-worker"
uv export --frozen --project source_worker --no-emit-project \
-o "$RUNNER_TEMP/source-worker-locked.txt"
uv pip install --python "$RUNNER_TEMP/source-worker/bin/python" \
-r "$RUNNER_TEMP/source-worker-locked.txt"
uv pip install --python "$RUNNER_TEMP/source-worker/bin/python" --no-deps \
"$RUNNER_TEMP/source-worker-wheel"/*.whl
- name: Configure the run's signer and paths
run: |
signer="$(openssl rand -hex 32)"
printf '::add-mask::%s\n' "$signer"
{
printf 'LOOM_JWT_SECRET=%s\n' "$signer"
printf 'FIXTURE=%s\n' "$RUNNER_TEMP/capacity"
printf 'LOOM_KNOWLEDGE_SOURCE_WORKER_ROUTES_FILE=%s\n' "$RUNNER_TEMP/capacity/loom/routes.json"
} >> "$GITHUB_ENV"
- name: Start ClickHouse
run: |
LOOM_CLICKHOUSE_IMAGE="$(bash dev/clickhouse_release.sh)"
export LOOM_CLICKHOUSE_IMAGE
bash dev/ci_start_clickhouse.sh
- name: Start Postgres with a synchronous standby
run: bash dev/ci_start_postgres.sh
- name: Apply migrations
run: .venv/bin/python -m server.core.schema.migrate
- name: Prepare the worker, its upstreams and the routes file
run: |
"$RUNNER_TEMP/source-worker/bin/python" -I bench/source_worker_copies_fixture.py prepare \
--dir "$FIXTURE" --org "capacity-${GITHUB_RUN_ID}" --collections "$COLLECTIONS" \
--concurrent "$WORKER_CONCURRENT" --concurrent-per-org "$WORKER_CONCURRENT_PER_ORG"
- name: Start the worker and its upstreams
run: |
nohup "$RUNNER_TEMP/source-worker/bin/python" -I bench/source_worker_copies_fixture.py serve \
--dir "$FIXTURE" --upstream-latency-ms "$UPSTREAM_LATENCY_MS" \
--credential-latency-ms "$CREDENTIAL_LATENCY_MS" > fixture.log 2>&1 &
echo "FIXTURE_PID=$!" >> "$GITHUB_ENV"
for _ in $(seq 1 60); do
test -f "$FIXTURE/ready" && exit 0
sleep 1
done
echo "the fixture never became ready" >&2
cat fixture.log >&2
exit 1
- name: Boot Loom from the checkout
run: |
PATH="$PWD/.venv/bin:$PATH" LOOM_WEB_WORKERS=1 nohup sh scripts/serve.sh > server.log 2>&1 &
echo "SERVER_PID=$!" >> "$GITHUB_ENV"
for _ in $(seq 1 90); do
curl -fsS http://localhost:7777/v1/health >/dev/null && exit 0
sleep 1
done
echo "the server never became healthy" >&2
tail -100 server.log >&2
exit 1
# STEP_BUDGET_SECONDS in the driver: it refuses passes that cannot fit, and writes its
# document after each pass so a run this limit stops keeps the passes it finished.
- name: Measure
timeout-minutes: 75
run: |
PYTHONPATH="$PWD" .venv/bin/python bench/source_worker_copies.py \
--base-url http://localhost:7777 --harness "$FIXTURE/harness.json" \
--sources "$SOURCES" --resources "$RESOURCES" --passes "$PASSES" \
--pass-interval "$PASS_INTERVAL" --refresh-interval "$REFRESH_INTERVAL" \
--faults "$FAULTS" --out source-worker-copies.json
- name: Stop the server and the fixture
if: always()
run: |
for pid in "${SERVER_PID:-}" "${FIXTURE_PID:-}"; do
if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
done
docker logs loom-ch > clickhouse.log 2>&1 || true
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: source-worker-copies
path: |
source-worker-copies.json
server.log
fixture.log
clickhouse.log
if-no-files-found: warn
retention-days: 30
8 changes: 8 additions & 0 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ Latency, throughput and storage at scale.
org, Postgres sizes, vacuum and a one-org dump, and `memory.set` at fixed rates over
several servers. Free with the fake providers; point it only at a private ClickHouse
and Postgres ([results](../docs/benchmarks/results.md#memory-at-scale)).
- **`source_worker_copies.py`** — how many owner-only source worker copies one Loom
process keeps served: sources set up through the worker setup operations, then fixed
sync passes, recording per-copy and per-check latency, copies confirmed per pass,
listing lapses, pass bound marks and the worker's 429s in one JSON file. Its fixture,
`source_worker_copies_fixture.py`, runs the bundled worker and two owned synthetic MCP
upstreams in the worker's own environment. Free; it runs in the dispatched `MCP source
worker copy capacity` workflow
([running](../docs/benchmarks/running.md#source-worker-copy-capacity)).
- **`ch_cost_by_op.py`** — ClickHouse cost per loom operation from
`system.query_log`, joined through the `log_comment` tag every loom query
carries (`"<op> <request_id>"` / `"worker.<name>"`).
Expand Down
Loading