Skip to content

proof of concept: benchmark long polling latency vs current short polling#137

Open
kirinrastogi wants to merge 5 commits intomainfrom
kirin/worker_long_poll
Open

proof of concept: benchmark long polling latency vs current short polling#137
kirinrastogi wants to merge 5 commits intomainfrom
kirin/worker_long_poll

Conversation

@kirinrastogi
Copy link
Copy Markdown
Contributor

@kirinrastogi kirinrastogi commented Feb 18, 2026

Still need to take a look at what this means for routing. Temporal uses long polling, and it can help here, in the best case it may reduce latency by 50ms.

5 runs with 10 enqueues each, running pnpm bench from the typescript_client dir in a loop and summarizing the results:

  ┌─────┬───────────────┬──────────────┬─────────┐
  │ Run │ Short Polling │ Long Polling │ Speedup │
  ├─────┼───────────────┼──────────────┼─────────┤
  │ 1   │ 3,791ms       │ 3,005ms      │ 1.26x   │
  ├─────┼───────────────┼──────────────┼─────────┤
  │ 2   │ 3,650ms       │ 2,844ms      │ 1.28x   │
  ├─────┼───────────────┼──────────────┼─────────┤
  │ 3   │ 3,613ms       │ 2,625ms      │ 1.38x   │
  ├─────┼───────────────┼──────────────┼─────────┤
  │ 4   │ 3,703ms       │ 2,653ms      │ 1.40x   │
  ├─────┼───────────────┼──────────────┼─────────┤
  │ 5   │ 3,803ms       │ 2,856ms      │ 1.33x   │
  └─────┴───────────────┴──────────────┴─────────┘

  Averages across 5 runs:
  - Short polling: 3,712ms (~371ms per task)
  - Long polling: 2,797ms (~280ms per task)
  - Speedup: 1.33x (long polling is ~25% faster)

actual output for one run:

 DEV  v4.0.14 /Users/kirin/src/gadget/silo/typescript_client


 ✓ test/worker-latency.bench.ts > enqueue-to-pickup latency 29028ms
     name                                   hz       min       max      mean       p75       p99      p995      p999      rme  samples
   · short polling (pollIntervalMs=50)  0.2290  3,803.77  4,703.52  4,367.70  4,703.52  4,703.52  4,703.52  4,703.52  ±27.95%        3
   · long polling                       0.3497  2,662.15  3,173.08  2,859.75  3,173.08  3,173.08  3,173.08  3,173.08  ±23.84%        3

 BENCH  Summary

  long polling - test/worker-latency.bench.ts > enqueue-to-pickup latency
    1.53x faster than short polling (pollIntervalMs=50)

 PASS  Waiting for file changes...
       press h to show help, press q to quit

Measures the delay between enqueuing a task and a worker picking it up
using short polling. With pollIntervalMs=50, the average latency is ~535ms
which demonstrates the need for long polling.
…vers

- Fix client RPC timeout: protobuf-ts GrpcTransport reads `timeout`, not
  `deadline`, from RpcOptions. The `deadline` field was silently ignored,
  leaving long-poll RPCs without a client-side timeout.
- Pin each long-poll poller to a fixed server index. Unlike short polling
  which cycles rapidly through servers, long-poll requests block for the
  full timeout duration, so cycling caused pollers to miss tasks on the
  server they weren't currently polling.
- Add `serverCount` getter to SiloGRPCClient for topology-aware poller
  configuration.
- Add integration tests: direct two-enqueue RPC test and 10-iteration
  worker latency test (avg ~225ms vs ~535ms with short polling).
Extract short-poll and long-poll latency benchmarks into a dedicated
bench file using vitest bench. Keep the long-poll correctness test in
integration tests.
@kirinrastogi kirinrastogi changed the title benchmark long polling latency vs current short polling proof of concept: benchmark long polling latency vs current short polling Feb 18, 2026
…ndex

Route long-poll requests by shard so the test works regardless of
cluster topology. Also fix rustfmt and make resolveShard public.
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