Skip to content

test(client): add concurrent missing-service ensure benchmark - #38568

Closed
armancharan wants to merge 4 commits into
anomalyco:v2from
armancharan:concurrent-ensure-bench
Closed

armancharan wants to merge 4 commits into
anomalyco:v2from
armancharan:concurrent-ensure-bench

Conversation

@armancharan

@armancharan armancharan commented Jul 23, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #38805

#38805

Parent: #36285

(Supersedes bot-closed #38569.)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a baseline concurrent-ensure benchmark for the missing-service case.

N clients (1, 2, 4, 7) call Service.ensure against an absent registration with a fake startup of EnsureSpawnGapMs / 2 (2.5s with today's 5s spawn gap).
The run reports contender launches, onStart announces, and recovery time until all clients are healthy.

No reconnect or jitter policy change — only current Service.ensure behavior, plus an exported EnsureSpawnGapMs so the harness stays tied to the real spawn gap.
One small test checks the setup with two clients.
A second test runs the full schedule and prints the JSON rows.

Locally, launches scale with N (1 → 1, 7 → 7) while recovery stays startup-bound (~3s).

How did you verify your code works?

cd packages/client && bun test test/concurrent-ensure.bench.test.ts --timeout 90000

Also re-ran packages/client test/service.test.ts.

Screenshots / recordings

N/A — not a UI layout change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Notes

Follow-up to the review ask on #37586: measure contender count and recovery latency for concurrent missing-service ensure before landing any reconnect-herd policy.
A later PR can keep only a change that reduces launches without delaying single-contender recovery.

Each row logs one all-healthy recoveryMs (wall time until every client resolves).
Happy to also log first-healthy if that's more useful for comparing policies later.

Measure contender launches and recovery latency when N clients ensure an
absent registration, and export EnsureSpawnGapMs so the harness stays
tied to the real spawn gap.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Use plain test names, split setup checks from the schedule report, and
keep a single recovery timer in the logged rows.

Co-authored-by: Cursor <[email protected]>
@armancharan
armancharan marked this pull request as ready for review July 23, 2026 21:32
@armancharan

Copy link
Copy Markdown
Author

Closing this. The production change is already on v2 (or this was only a follow-up test/bench). Not worth keeping the PR open.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant