Skip to content

feat(ai-gateway): add regional latency benchmark - #379

Open
dtice25 wants to merge 10 commits into
masterfrom
devin/1788294803-regional-ai-gateway
Open

feat(ai-gateway): add regional latency benchmark#379
dtice25 wants to merge 10 commits into
masterfrom
devin/1788294803-regional-ai-gateway

Conversation

@dtice25

@dtice25 dtice25 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a regional AI gateway latency benchmark where each runner location is a dimension. Each invocation runs one region, tags every record with region, and multiple invocations can share the same --run-key to appear as one platform run.

When a --run-key is used, the benchmark suffixes each provider participant slug with the runner region (<provider>-<region>) so sibling regional runners register distinct participants. The original provider name is preserved in a new displayName field so legacy JSON and SVG output stay readable.

What changed

  • benchmarks/ai-gateway/ai-gateway-regional.bench.ts (new): single-region-per-run benchmark that reads BENCH_REGION or --ai-gateway-region. Defaults to 5 cold + 5 warm iterations and honors --iterations / --ai-gateway-iterations-cold / --ai-gateway-iterations-warm.
  • benchmarks/ai-gateway/shared-task.ts: resolveAIGatewayRegionalPhases builds <region>:cold / <region>:warm phases, makeAIGatewayTask tags records with region, and parsePhase extracts region/mode from the phase string.
  • benchmarks/ai-gateway/types.ts: removed the unused regionalEndpoints field; added optional displayName to AIGatewayProviderConfig for clean legacy/SVG output when participant slugs carry extra qualifiers.
  • benchmarks/ai-gateway/legacy-results.ts: emits provider from displayName (falling back to the participant slug).
  • package.json: added bench:ai-gateway-regional scripts.
  • .github/workflows/ai-gateway-regional-benchmarks.yml (new): weekly/ manually-triggered matrix that runs one job per region with the same --run-key. The runs-on value currently uses namespace-profile-default with vault grants as a placeholder; region-specific Namespace runner profiles/labels must be configured for actual regional scheduling. All uses: actions are pinned to commit SHAs, pnpm install --frozen-lockfile is used for all triggers, the pnpm cache is disabled, and unused permissions are removed.

Usage

BENCH_REGION=us-east-1 pnpm bench:ai-gateway-regional
# or join four regional runners into one platform run
BENCH_REGION=eu-west-1 npx tsx packages/benchsdk-runner/dist/bin.js run \
  benchmarks/ai-gateway/ai-gateway-regional.bench.ts --run-key regional-ai-gateway-123

Link to Devin session: https://app.devin.ai/sessions/e421351b95ad4ddba4959a7c2aa41d92
Open in Devin Desktop: https://app.devin.ai/desktop/session/e421351b95ad4ddba4959a7c2aa41d92?variant=devin
Requested by: @dtice25


Devin Review

- Add regional endpoint support to AIGatewayProviderConfig

- Extend shared task to parse <region>:<mode> phases and route to per-region endpoints

- Add ai-gateway-regional.bench.ts with 4 default regions and 5 cold/warm iterations each

- Group scoring by region and write per-region legacy results

- Add pnpm scripts for running the regional benchmark

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@open-cla

open-cla Bot commented Sep 1, 2026

Copy link
Copy Markdown

Contributor License Agreement

All contributors are covered by a CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

dtice25 and others added 2 commits September 1, 2026 20:37
Ensure --ai-gateway-regions cannot consume a following flag as a region and the equals form rejects an empty value.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Run one region per invocation, supplied via BENCH_REGION or --ai-gateway-region.

The same provider endpoints are used; region differences come from runner location.

Records are tagged with region and legacy results are written per region.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

resolveAIGatewayRegionalPhases now receives process.argv flags plus the resolved region, so --iterations / --ai-gateway-iterations-cold / --ai-gateway-iterations-warm are honored.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: resolveAIGatewayRegionalPhases now receives [...process.argv.slice(2), '--ai-gateway-regions', region], so --iterations, --ai-gateway-iterations-cold, and --ai-gateway-iterations-warm are parsed correctly. Verified with tsx -e that us-east-1:cold gets 2 iterations and us-east-1:warm gets 1 when those flags are passed. Pushed in 0f41d12.

devin-ai-integration[bot]

This comment was marked as resolved.

resolveAIGatewayRegionalPhases now throws when the generic --iterations flag is <= 0.

The regional benchmark now throws instead of exiting 0 when no phases remain.

Per-phase --ai-gateway-iterations-* 0 still disables that phase as intended.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: resolveAIGatewayRegionalPhases now throws when the generic --iterations flag is <= 0, and the benchmark throws when no phases remain. Per-phase --ai-gateway-iterations-* 0 still disables just that phase. Verified: --ai-gateway-iterations-cold 0 yields only warm phases, --iterations 0 errors, and --ai-gateway-iterations-cold 2 --ai-gateway-iterations-warm 1 yields 2 cold + 1 warm. Pushed in 0f341bd.

dtice25 and others added 2 commits September 1, 2026 21:00
Regions are runner locations, not per-provider endpoints, so the unused

regionalEndpoints config and resolveProviderForRegion routing are removed.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

superagent-security[bot]

This comment was marked as resolved.

dtice25 and others added 2 commits September 1, 2026 21:49
… per region

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…tions, frozen lockfile

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: added the Namespace vault object list/describe grants to the runs-on value so load-vault-secrets.sh can retrieve credentials in each regional leg.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: when --run-key is used the benchmark suffixes each provider participant slug with the runner region (<provider>-<region>) and stores the original provider name in the new displayName field. Sibling regional runners now register distinct participant identities while data.region still drives scoring.groupBy. Without --run-key (e.g. per-provider local runs) the original slugs are preserved.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: updated the load-vault-secrets.sh regex to load the full set of gateway credential env vars used by benchmarks/ai-gateway/providers.ts, matching the Anthropic-family leg of the existing AI gateway workflow.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: removed the schedule-only pnpm update --ignore-scripts branch; all workflow triggers now use pnpm install --frozen-lockfile --ignore-scripts so scheduled runs don't pull unreviewed dependency updates in a secret-bearing job.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: pinned actions/checkout, pnpm/action-setup, actions/setup-node, namespacelabs/nscloud-setup, and actions/upload-artifact to verified full commit SHAs with the version tag in a comment.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: removed cache: 'pnpm' from actions/setup-node so the privileged benchmark job does not restore a shared dependency cache before loading secrets.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: removed the unused pull-requests: write permission from the workflow.

…filter

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed: added RAMP_ROUTER_API_KEY to the load-vault-secrets.sh regex so the regional workflow loads Ramp credentials alongside the other gateway keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant