Repository navigation
A dispatched hosted workflow measures how many source worker copies one Loom process keeps served #2196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zlareb1
wants to merge
4
commits into
main
Choose a base branch
from
bench/mcp-source-worker-capacity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,813
−1
Open
A dispatched hosted workflow measures how many source worker copies one Loom process keeps served #2196
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c8562ce
A dispatched hosted workflow measures how many source worker copies o…
zlareb1 8f5fde3
The capacity driver counts unreached sources as a cut pass and keeps …
zlareb1 a18c1d3
The capacity driver records a turn that raised as reached and keeps i…
zlareb1 d42f250
The capacity driver faults stored copies and bounds every pass and se…
zlareb1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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_intervalis a workflow input and the driver spacesrun_sync()with it, including back-to-back when it is 0.LOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDSstays 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)
bench/source_worker_copies.py#L772-L775Reviewed by Cursor Bugbot for commit c8562ce. Configure here.