Skip to content

Fix endpoint muxer TODOs and make threading use vert.x. - #7883

Open
master312 wants to merge 6 commits into
masterfrom
fix/endpoint-muxer-threading-refactor
Open

Fix endpoint muxer TODOs and make threading use vert.x.#7883
master312 wants to merge 6 commits into
masterfrom
fix/endpoint-muxer-threading-refactor

Conversation

@master312

Copy link
Copy Markdown
Contributor

@dmtan90

dmtan90 commented Jun 11, 2026

Copy link
Copy Markdown

🤖 AI Code Review Summary

This is a significant and positive architectural shift from dedicated threads per muxer to a shared Vertx WorkerExecutor pool. This should greatly improve scalability under high load. The move to executeBlocking with a periodic timer is appropriate for this use case. My primary concerns are around native memory management (ensuring all AVPackets in the queue are freed in all circumstances) and the potential CPU overhead of the 10ms periodic timer if the system scales to a large number of concurrent muxers. Please ensure the test suite is robust enough to cover the async nature of the new draining mechanism.

📄 Inline File Comments:

  • src/main/java/io/antmedia/muxer/EndpointMuxer.java: The vertx.setPeriodic(10, ...) timer runs every 10ms. This is quite aggressive and could lead to high CPU overhead if many muxers are active. Could this interval be adjusted or made configurable? Also, check if this timer is properly cancelled during all shutdown paths to prevent leaks.
  • src/main/java/io/antmedia/muxer/EndpointMuxer.java: LinkedBlockingQueue<AVPacket>: Ensure all paths (especially error cases and teardown) correctly free these AVPacket instances to prevent native memory leaks. The current freeQueuedPackets() helper is a good start, but verify it covers all edge cases.
  • src/test/java/io/antmedia/test/MuxerUnitTest.java: The test testTeardownDrainsQueuedPackets (renamed from testShutdownWorkerQueueFullDrainsPacket) likely needs to be carefully verified to ensure it properly mocks/handles the new Vertx-based worker pool lifecycle. Ensure that the test waits long enough for the async drain() task to complete before asserting the queue state.

@master312 master312 changed the title Endpoint muxer threading refactor. Fix endpoint muxer TODOs and make threading use vert.x. Jun 12, 2026
</constructor-arg>
<!-- * The default number of event loop threads to be used = 2 * number of cores on the machine -->
</bean>

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.

I think we may use the available pool. If there is blocking error logs it gives us some information aabout the system.

@master312
master312 force-pushed the fix/endpoint-muxer-threading-refactor branch from b77c881 to b49b21d Compare July 20, 2026 11:39
@sonarqubecloud

Copy link
Copy Markdown

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