Skip to content

perf(decisionindex,gateway): parallelize independent multi-pass /v1/systemone batches and Round-1 brackets - #96

Merged
ghchinoy merged 1 commit into
GoogleCloudPlatform:mainfrom
ghchinoy:perf/adapter-parallel-passes
Nov 21, 2026
Merged

ghchinoy merged 1 commit into
GoogleCloudPlatform:mainfrom
ghchinoy:perf/adapter-parallel-passes

Conversation

@ghchinoy

Copy link
Copy Markdown
Collaborator

Summary

Eliminates unnecessary serial execution across independent passes in the /v1/systemone adapter while keeping prompts, scoring, and response shapes identical:

  • Bounded concurrency (pkg/decisionindex/engine.go): wires the existing EngineOptions.MaxConcurrency (default 4) via a new runBounded helper:
    • Single-pass requests and MaxConcurrency <= 1 run inline with zero goroutine overhead.
    • Multi-batch standard questions (>8 questions) and multiple wide questions (>26 options) execute concurrently up to MaxConcurrency.
    • Wide-question Round-1 bracket batches (>160 options, e.g., >8 brackets) execute concurrently before Round-2 Finals.
    • First upstream error cancels the derived context so sibling passes abort promptly.
  • Gateway knob & telemetry (cmd/serve.go):
    • Adds --systemone-max-concurrency / DGEM_SYSTEMONE_MAX_CONCURRENCY (default 4; set 1 for serial comparison or rate-limited backends).
    • Records dgem.systemone.server_ms on gateway adapter spans alongside dgem.systemone.forward_passes so wall time vs sum-of-passes compute time is directly observable.

Test plan

  • Added pkg/decisionindex/parallel_passes_test.go covering multi-batch overlap, serial MaxConcurrency=1 mode, wide-option Round-1 parallelism, and error cancellation.
  • go test -race ./cmd/... ./pkg/... and go -C examples test ./... — all pass.
  • golangci-lint (staticcheck, unused) — 0 findings on edited files.
  • make check-public — passed.

…ystemone batches and Round-1 brackets

Multi-pass /v1/systemone adapter requests previously executed every standard
slot batch (>8 questions), every wide-option question (>26 options), and every
Round-1 bracket batch (>160 options) strictly serially even though
EngineOptions.MaxConcurrency (default 4) was already defined.

- Add runBounded helper in pkg/decisionindex/engine.go: runs single-task or
  MaxConcurrency<=1 requests inline (zero goroutine overhead), and dispatches
  multi-task batches concurrently up to MaxConcurrency with context
  cancellation on first error.
- Parallelize independent standard batches and wide questions in
  ExecuteSystemOne, and independent Round-1 bracket batches in
  evaluateWideQuestionTournament (Round-2 Finals still waits on Round 1).
- Expose --systemone-max-concurrency / DGEM_SYSTEMONE_MAX_CONCURRENCY (default
  4; 1 = serial) in dgem serve and log dgem.systemone.server_ms on gateway
  adapter spans alongside dgem.systemone.forward_passes.
- Add race-tested unit tests in pkg/decisionindex/parallel_passes_test.go
  covering multi-batch overlap, serial MaxConcurrency=1 mode, wide tournament
  Round-1 parallelism, and error cancellation.
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