Skip to content

feat(host-rpc): add backpressure controls to notifier#123

Merged
prestwich merged 2 commits intodevelopfrom
prestwich/host-rpc-backpressure
Mar 30, 2026
Merged

feat(host-rpc): add backpressure controls to notifier#123
prestwich merged 2 commits intodevelopfrom
prestwich/host-rpc-backpressure

Conversation

@prestwich
Copy link
Copy Markdown
Member

Summary

Adds backpressure controls to RpcHostNotifier to prevent unbounded RPC fan-out and stale header processing. Closes ENG-2104.

  • Bounded RPC concurrency: Replace unbounded FuturesOrdered with stream::buffered(max_rpc_concurrency) (default 8, configurable via SIGNET_HOST_MAX_RPC_CONCURRENCY)
  • Header coalescing: New Latest<S> stream adapter drains buffered subscription headers and yields only the most recent, discarding stale intermediates
  • Metrics: New host_rpc.headers_coalesced counter tracks skipped headers

Test plan

  • Unit tests for Latest<S> pass (cargo t -p signet-host-rpc)
  • Verify configurable concurrency limit threads through builder and env config
  • Monitor headers_coalesced metric under load to confirm coalescing behavior

🤖 Generated with Claude Code

Bound concurrent RPC block fetches with configurable max_rpc_concurrency
(default 8) and coalesce stale subscription headers via Latest<S> stream
adapter to prevent slow-consumer backlog buildup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich requested a review from a team as a code owner March 30, 2026 12:51
@prestwich prestwich requested review from Evalir and Fraser999 and removed request for a team March 30, 2026 12:51
Copy link
Copy Markdown
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

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

Non-blocking nitpicks only.

/// Set the maximum number of concurrent RPC block fetches (default: 8).
///
/// Values below 1 are clamped to 1.
pub const fn with_max_rpc_concurrency(mut self, max_rpc_concurrency: usize) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could add with_max_rpc_concurrency to the doc example above here.

Also, we clamp here, but not in with_backfill_batch_size or with_buffer_capacity which is a bit inconsistent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good call

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

in 3192297

…mple

Add consistent minimum-value clamping (to 1) for buffer_capacity and
backfill_batch_size to match max_rpc_concurrency. Add the missing
with_max_rpc_concurrency call to the builder doc example.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich enabled auto-merge (squash) March 30, 2026 15:04
@prestwich prestwich merged commit 24bd74b into develop Mar 30, 2026
6 checks passed
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.

2 participants