FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

node-api: faster threadsafe_function by indutny · Pull Request #38506 · nodejs/node · GitHub

/ node Public

node-api: faster threadsafe_function - #38506

Closed
indutny wants to merge 2 commits into
nodejs:masterfrom
indutny:feature/faster-threadsafe-function
Closed

node-api: faster threadsafe_function#38506
indutny wants to merge 2 commits into
nodejs:masterfrom
indutny:feature/faster-threadsafe-function

Conversation

indutny commented May 2, 2021

Copy link
Copy Markdown
Member

Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

  1. There's a queued call already
  2. Push() is called while the main thread was running
    threadsafe_function

indutny requested a review from addaleax May 2, 2021 19:15
github-actions Bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 2, 2021

indutny commented May 2, 2021

Copy link
Copy Markdown
Member Author

Sorry, this is not yet ready for review. I've realized that the removal of uv_idle_t is no longer justified now that the iteration count is limited. Give me a minute to address this.

Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

indutny commented May 2, 2021

Copy link
Copy Markdown
Member Author

Now fixed. PTAL @addaleax

indutny force-pushed the feature/faster-threadsafe-function branch from 37b10a7 to 42ccd43 Compare May 2, 2021 19:21
Comment thread src/node_api.cc
addaleax added the node-api Issues and PRs related to the Node-API. label May 2, 2021
Comment thread src/node_api.cc
return napi_generic_failure;
}
queue.push(data);
Send();

indutny May 2, 2021
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I've swapped the order since uv_async_send() error is treated as a hard failure and it is more logical to push before the notification.

// `kMaxIterationCount` in `src/node_api.cc`
.then(() => testWithJSMarshaller({
threadStarter: 'StartThreadNonblocking',
maxQueueSize: binding.ARRAY_LENGTH >>> 1,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks stupid, but there is an assert in the binding that the queue block at least once, and I didn't want to change .c code 😂

indutny commented May 2, 2021

Copy link
Copy Markdown
Member Author

/me sets a reminder to land this after 48 hours.

Copy link
Copy Markdown
Collaborator

jasnell added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. and removed needs-ci PRs that need a full CI run. labels May 4, 2021
indutny added a commit that referenced this pull request May 5, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: #38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

indutny commented May 5, 2021

Copy link
Copy Markdown
Member Author

Landed in 7abc7e4. Thanks for reviews!

@jasnell @addaleax what's our process for backports? Do I need to submit a PR for 14.x? I assume this should land cleanly there since the code didn't change.

indutny closed this May 5, 2021
indutny deleted the feature/faster-threadsafe-function branch May 5, 2021 01:41
indutny mentioned this pull request May 5, 2021

indutny commented May 5, 2021

Copy link
Copy Markdown
Member Author

Opened a backport PR: #38543 . Let me know if I messed this up!

indutny added a commit to indutny/io.js that referenced this pull request May 5, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: nodejs#38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

indutny commented May 5, 2021

Copy link
Copy Markdown
Member Author

Here's a PR against v16.x-staging: #38547

indutny-signal pushed a commit to indutny/electron that referenced this pull request May 5, 2021
indutny added a commit to indutny/electron that referenced this pull request May 5, 2021
deepak1556 pushed a commit to electron/electron that referenced this pull request May 6, 2021
trop Bot pushed a commit to electron/electron that referenced this pull request May 6, 2021
trop Bot pushed a commit to electron/electron that referenced this pull request May 6, 2021
codebytere pushed a commit to electron/electron that referenced this pull request May 6, 2021
MarshallOfSound pushed a commit to electron/electron that referenced this pull request May 7, 2021
Backports: nodejs/node#38506

Co-authored-by: Fedor Indutny <fedor@indutny.com>
MarshallOfSound pushed a commit to electron/electron that referenced this pull request May 7, 2021
Backports: nodejs/node#38506

Co-authored-by: Fedor Indutny <fedor@indutny.com>

Copy link
Copy Markdown
Member

We have a persistent failure in the node-addon-api testing which started around this time. nodejs/node-addon-api#994

targos pushed a commit that referenced this pull request May 17, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: #38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere added a commit to electron/electron that referenced this pull request May 20, 2021
targos pushed a commit that referenced this pull request May 30, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: #38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere added a commit to electron/electron that referenced this pull request May 31, 2021
codebytere added a commit to electron/electron that referenced this pull request May 31, 2021
targos pushed a commit that referenced this pull request Jun 5, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: #38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jun 5, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: #38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere added a commit to electron/electron that referenced this pull request Jun 8, 2021
codebytere added a commit to electron/electron that referenced this pull request Jun 9, 2021
codebytere added a commit to electron/electron that referenced this pull request Jun 10, 2021
targos pushed a commit that referenced this pull request Jun 11, 2021
Invoke threadsafe_function during the same tick and avoid marshalling
costs between threads and/or churning event loop if either:

1. There's a queued call already
2. `Push()` is called while the main thread was running
   threadsafe_function

PR-URL: #38506
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL