Skip to content

feat: serialize dispatch per worker - #91

Merged
YuminosukeSato merged 2 commits into
pr/1-test-infrafrom
pr/2-core-dispatch
Feb 6, 2026
Merged

YuminosukeSato merged 2 commits into
pr/1-test-infrafrom
pr/2-core-dispatch

Conversation

@YuminosukeSato

Copy link
Copy Markdown
Owner

Summary

  • Enforce per-worker serialization to eliminate dispatch collisions and HOL blocking.
  • Add MaxInFlightPerWorker and keep MaxInFlight as global backpressure.
  • Make Call/Shutdown concurrency-safe.

Changes

  • Add per-worker inflight gate and worker-available signaling.
  • Protect Call lifecycle with activeCallsWG and callsMu.
  • Add default MaxInFlightPerWorker and wire through pool creation.

Test plan

  • go test -v -race ./...

@github-actions github-actions Bot added lang/go Go code changes area/pool Worker pool management labels Feb 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34f0c2c746

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/pyproc/pool.go Outdated
Comment on lines +402 to +405
// Wait for in-flight calls to complete before closing pools
p.callsMu.Lock()
p.callsMu.Unlock()
p.activeCallsWG.Wait()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bound shutdown wait for active calls

Shutdown now waits on p.activeCallsWG.Wait() before closing connections or stopping workers, so a long-running or hung in-flight call can block shutdown indefinitely. Because this method ignores its context.Context parameter, callers cannot time-bound this wait during rollout/termination, which can wedge service shutdown in production. Consider making this wait context-aware (or stopping workers before/while waiting) so shutdown remains bounded.

Useful? React with 👍 / 👎.

Move activeCallsWG.Wait() inside the callsMu critical section to
satisfy staticcheck SA2001 (empty critical section). The lock still
serves as a barrier ensuring all in-progress Call() goroutines have
completed their Add(1) before Wait() is called.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@YuminosukeSato
YuminosukeSato merged commit 3e92bd1 into pr/1-test-infra Feb 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/pool Worker pool management lang/go Go code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant