Skip to content

WIP: counter latency monitor#5011

Draft
NathanFlurry wants to merge 1 commit into
mainfrom
05-09-wip_counter_latency_monitor
Draft

WIP: counter latency monitor#5011
NathanFlurry wants to merge 1 commit into
mainfrom
05-09-wip_counter_latency_monitor

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app
Copy link
Copy Markdown

railway-app Bot commented May 10, 2026

🚅 Deployed to the rivet-pr-5011 environment in rivet-frontend

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web May 10, 2026 at 2:22 am
frontend-cloud ❌ Build Failed (View Logs) Web May 10, 2026 at 2:12 am
ladle ❌ Build Failed (View Logs) Web May 10, 2026 at 2:12 am
frontend-inspector ❌ Build Failed (View Logs) Web May 10, 2026 at 2:12 am
mcp-hub ✅ Success (View Logs) Web May 10, 2026 at 2:11 am
kitchen-sink ❌ Build Failed (View Logs) Web May 10, 2026 at 2:11 am

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 10, 2026

Review: WIP Counter Latency Monitor

This PR adds two new files to the kitchen-sink example: a latency load-test script (counter-latency.ts) and a raw WebSocket ping-pong actor (ping-pong-counter.ts). Overall the script is well-structured and clearly documented. The two-mode design (rtt vs. concurrent) covers the main latency measurement use cases. A few issues need attention before merge.

Bugs / Correctness

pingPongCounter is not registered in src/index.ts

The actor in ping-pong-counter.ts is defined but never imported or added to the registry. It cannot be reached by any client. Either register it or explain in the PR description why it is intentionally excluded.

inflight array grows unbounded in infinite mode

In runRttMode, resolved promises are pushed into inflight but never removed. When BATCHES=0 (infinite, the default), the loop never exits and await Promise.all(inflight) is unreachable, so the array grows without bound for the process lifetime. Settled promises are small but this will accumulate over hours or days of running. Fix: drain completed promises periodically, or track in-flight count with a simple counter instead of retaining promise handles.

Relationship between the two new files is unclear

The latency script uses client.counter (the existing counter actor with increment / noop). The new pingPongCounter actor has neither of those actions and is not referenced anywhere in the script. If the intent is to eventually swap the script to use pingPongCounter, that work should be completed here; otherwise one of the two files is unnecessary.

Code Quality

any types in ping-pong-counter.ts

If the WebSocket type is not yet exported by the framework, import or inline a minimal interface rather than using any. At minimum, let parsed: unknown with a proper type guard would be safer.

Comment says orange but implementation uses a smooth gradient

The top-of-file comment describes three discrete color thresholds (green/orange/red), but the actual implementation uses a continuous green-to-red gradient via gradientColor. The comment should be updated to match what the code actually does.

Log helpers duplicate timestamp/prefix construction

logConnect, logIncrement, logDisconnect, and logConnectError each rebuild the same ts + prefix string inline. Extracting a small formatPrefix(worker) helper would remove the repetition.

BATCHES env var parsing lacks validation

If BATCHES is set to a non-numeric string (e.g. BATCHES=foo), this silently becomes NaN. That makes BATCHES === 0 false and workerId < BATCHES always false, so the loop exits immediately with no error. Add an explicit guard with a clear error message, matching the validation pattern already used for --interval.

Minor / Style

  • ARGS.concurrency non-null assertion in runConcurrentMode is safe because validation already enforces it, but an explicit throw at the top of the function would be more readable and self-documenting.
  • Consider whether interval === 0 should be allowed. An interval of 0 means the rtt loop spins with no back-pressure. The current validator allows it (interval < 0 not <= 0); document this as intentional if it is a supported max throughput mode.
  • The top-level ARGS, BATCHES, and SERIAL constants are evaluated at module load time before main() runs. Fine for a script, but worth noting if this file is ever imported in tests.

Summary

The PR is draft with all checklist items unchecked, so the above are expected to be resolved before merge. The highest-priority items are: wiring pingPongCounter into the registry (or removing it), fixing the inflight unbounded growth, and clarifying the intended relationship between the two new files.

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