Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(emqx_cm): use a dedicated pool for channel cleanup #12336

Conversation

SergeTupchiy
Copy link
Contributor

@SergeTupchiy SergeTupchiy commented Jan 16, 2024

This is to isolate channels cleanup from other async tasks (like routes cleanup), as channels cleanup can be quite slow under high network latency conditions.

Fixes EMQX-11743

Release version: v/e5.?

Summary

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Added property-based tests for code which performs user input validation
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • Schema changes are backward compatible

Checklist for CI (.github/workflows) changes

  • If changed package build workflow, pass this action (manual trigger)
  • Change log has been added to changes/ dir for user-facing artifacts update

@SergeTupchiy SergeTupchiy requested review from lafirest and a team as code owners January 16, 2024 16:04
@SergeTupchiy SergeTupchiy force-pushed the EMQX-11743-dedicated-channel-cleanup-pool branch from 7e4b5f6 to f70f834 Compare January 16, 2024 16:07
async_submit_to_pool(?POOL, Fun, Args).

-spec submit_to_pool(any(), task()) -> any().
submit_to_pool(Pool, Task) ->
Copy link
Contributor Author

@SergeTupchiy SergeTupchiy Jan 16, 2024

Choose a reason for hiding this comment

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

Note: added a new function with a distinct name to avoid having different semantics under the same function arity, which would look quite messy, e.g.:

async_submit(Fun, Args) when is_function(Fun) ->
    async_submit(?POOL, Fun, Args);
async_submit(Pool, Task) ->
    ...

@@ -353,10 +353,12 @@ test_stepdown_session(Action, Reason) ->
%% to sync with the pool workers.
%% The number of tasks should be large enough to ensure all workers have
%% the chance to work on at least one of the tasks.
flush_emqx_pool() ->
flush_emqx_cm_pool() ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: this seems almost identical to emqx_pool:flush_async_tasks/1?

Copy link
Contributor Author

@SergeTupchiy SergeTupchiy Jan 16, 2024

Choose a reason for hiding this comment

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

Indeed, replaced it with `emqx_pool:flush_async_tasks/1, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, failed to push this fix 🙈 , will issue a follow-up PR..

This is to isolate channels cleanup from other async tasks (like routes cleanup),
as channels cleanup can be quite slow under high network latency conditions.

Fixes: EMQX-11743
@SergeTupchiy SergeTupchiy force-pushed the EMQX-11743-dedicated-channel-cleanup-pool branch from f70f834 to b472b56 Compare January 16, 2024 17:08
@SergeTupchiy SergeTupchiy merged commit ed78f24 into emqx:master Jan 16, 2024
160 of 163 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