Skip to content

test: add MultiThread relay test mode#363

Open
afrind wants to merge 3 commits into
mainfrom
pr363
Open

test: add MultiThread relay test mode#363
afrind wants to merge 3 commits into
mainfrom
pr363

Conversation

@afrind

@afrind afrind commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Add RelayMode::MultiThread to the MoQRelayTest parameterized suite so the
relay is exercised across an executor boundary, alongside the existing
SingleThread mode.

Fixture (MoqxRelayTestFixture.h/.cpp, MoqxRelayTestModes.cpp):

  • New RelayMode::MultiThread enum value, instantiated in the AllModes suite.
  • SetUp() starts a ScopedEventBaseThread, wires the relay onto it via
    setRelayExec, and wraps it in PublisherCrossExecFilter /
    SubscriberCrossExecFilter. TearDown() drains pending relay-exec tasks and
    tears down in order to avoid use-after-free on NamespaceTree.
  • TestMoQExecutor::drive() does a loopOnce(), then in MT mode round-trips
    through the relay EVB twice to flush task->relay and relay-created tasks.
  • Add driveIfMultiThread(), make verifyOnRelayExec() hop to the relay EVB,
    and add driveUntil(pred) to advance async cascades deterministically
    instead of using a fixed drive count (capped at one iter in ST mode).

Tests (DataPlane, NGR, Peer, Publish, SubNs, Subscribe):

  • Insert driveIfMultiThread() where work crosses executors.
  • Replace fixed-drive-then-read with driveUntil() plus std::atomic flags.
  • DuplicateSubgroupCancelledWhenNoActiveConsumers splits ST/MT expectations:
    in MT the CrossExecFilter defers the CANCELLED error to the next op, so it
    probes via endOfSubgroup().
  • Add reset() calls to simulate the publisher/QUIC resetting open streams.

Test Plan:



This change is Reviewable

afrind added 3 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.
Add RelayMode::MultiThread to the MoQRelayTest parameterized suite so the
relay is exercised across an executor boundary, alongside the existing
SingleThread mode.

Fixture (MoqxRelayTestFixture.h/.cpp, MoqxRelayTestModes.cpp):
- New RelayMode::MultiThread enum value, instantiated in the AllModes suite.
- SetUp() starts a ScopedEventBaseThread, wires the relay onto it via
  setRelayExec, and wraps it in PublisherCrossExecFilter /
  SubscriberCrossExecFilter. TearDown() drains pending relay-exec tasks and
  tears down in order to avoid use-after-free on NamespaceTree.
- TestMoQExecutor::drive() does a loopOnce(), then in MT mode round-trips
  through the relay EVB twice to flush task->relay and relay-created tasks.
- Add driveIfMultiThread(), make verifyOnRelayExec() hop to the relay EVB,
  and add driveUntil(pred) to advance async cascades deterministically
  instead of using a fixed drive count (capped at one iter in ST mode).

Tests (DataPlane, NGR, Peer, Publish, SubNs, Subscribe):
- Insert driveIfMultiThread() where work crosses executors.
- Replace fixed-drive-then-read with driveUntil() plus std::atomic flags.
- DuplicateSubgroupCancelledWhenNoActiveConsumers splits ST/MT expectations:
  in MT the CrossExecFilter defers the CANCELLED error to the next op, so it
  probes via endOfSubgroup().
- Add reset() calls to simulate the publisher/QUIC resetting open streams.

Test Plan:

@gmarzot gmarzot 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.

@gmarzot reviewed 23 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on akash-a-n, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).

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