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

Gold-180 - fix: inproper nodejs task scheduling, use mpsc for multi_send #10

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

kgmyatthu
Copy link

@kgmyatthu kgmyatthu commented Jul 15, 2024

In multi send neon binding the function is spawning tokio
threads for every ip:port pair along with O(n) oneshot channel pairs
with nodejs taskqueue scheduling callbacks for O(n) n = target addresses. In addition we have O(n) spawn for actual connection outbound stuff (this part is legit). This make multi send spawn O(n^2) tokio threads.
This code is also having problem with failure to give control back to runtime thread and lost thread wakers on non-ideal/edge situation. This lead to zombie thread , tokio runtime thread not being able to get back resources for the during of the whole application cycle. (Node cycle).

This PR fixes this, by using MPSC channel, eliminate thread spawning unnecessarily in neon bindings, thus reducing thread spawn back to O(n).

@kgmyatthu kgmyatthu self-assigned this Jul 15, 2024
shardus_net/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Author

@kgmyatthu kgmyatthu left a comment

Choose a reason for hiding this comment

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

I'm ok with getting this in

kgmyatthu and others added 5 commits August 16, 2024 19:07
The why - In multi send neon binding the function is spawning tokio
threads for every ip:port pair along with O(n) oneshot channel pairs
with nodejs callback function being Atomically reference counted this
bring no benefit whatsoever while impact performance and lost thread
yeilding and lost thread wakers on non-ideal/edge situation.
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