Skip to content

relay: isolate relay state on dedicated executor to support multiple I/O threads#362

Open
afrind wants to merge 2 commits into
mainfrom
pr362
Open

relay: isolate relay state on dedicated executor to support multiple I/O threads#362
afrind wants to merge 2 commits into
mainfrom
pr362

Conversation

@afrind

@afrind afrind commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

afrind added 2 commits June 6, 2026 12:18
Adds a use_relay_thread boolean config option (default: true) that
controls whether relay state is isolated on a dedicated executor thread.
Disabling it is intended for baseline performance comparison only.

Also removes the hard error that rejected threads > 1, replacing it
with a targeted check: threads > 1 requires use_relay_thread=true.
This unlocks the config validation only — threads > 1 with
use_relay_thread=true will race on shared relay state until the
following commit wires up the dedicated relay executor.

@akash-a-n akash-a-n left a comment

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.

:lgtm:

@akash-a-n reviewed 25 files and all commit messages, and made 2 comments.
Reviewable status: 25 of 26 files reviewed, 1 unresolved discussion (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).


src/MoqxRelay.cpp line 872 at r4 (raw file):

    }
  }
  if (session.get() == upstreamSession.get()) {

is self fetch not a concern anymore? Claude just flagged this.

@michalhosna michalhosna left a comment

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.

@michalhosna made 1 comment.
Reviewable status: 25 of 26 files reviewed, 2 unresolved discussions (waiting on afrind, gmarzot, mondain, Oxyd, peterchave, suhasHere, and TimEvens).


src/MoqxRelay.h line 129 at r4 (raw file):

  // cross-executor filters. relayExec must outlive this relay.
  // If not set (default), all operations run on the calling thread.
  void setRelayExec(folly::Executor* relayExec) { relayExec_ = relayExec; }

It seem unsafe to call setRelayExec after the relay starts to do anything, so why is it not in constructor? Or some kind of safe-check that it's called only once.

Looking at #363 its used there in resetRelay in the test fixture, but I am not sure it's correct. When alling this on relay where ownedRelayExec_ != null, the ownedRelayExec_ stays dangling, that's probably fine?

Is this whole method with sharing executor tests only? Should we gate it more?

Reviewing this one without #363 seems to not make much sense. I'll redo my review there.

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.

3 participants