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

src: lazily load internalBinding('uv') and build the errmap lazily #25143

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

This removes the internalBinding('uv') call from the normal
bootstrap for now, and avoids building errmap by default which
expands to a lot of calls into V8.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originated in Node.js core. libuv Issues and PRs related to the libuv dependency or the uv binding. util Issues and PRs related to the built-in util module. labels Dec 19, 2018
@joyeecheung
Copy link
Member Author

cc @addaleax

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Btw, I’ve also thought about creating a static array from the macro here, instead of generating the full code for each entry… that might make things a bit easier as well?

src/uv.cc Outdated Show resolved Hide resolved
@joyeecheung
Copy link
Member Author

creating a static array from the macro here

I don't think I follow..what do you mean by creating a static array?

@addaleax
Copy link
Member

@joyeecheung This might not compile because I wrote it here in Github, but I think you get the idea:

static const struct {
  int value;
  const char* name;
  const char* message;
} errors[] = {
#define V(name, msg) { UV_##name, #name, msg }, 
  UV_ERRNO_MAP(V)
#undef V
  { 0, nullptr, nullptr }
};

for (const auto* error = errors; error->name != nullptr; error++) {
    Local<Value> arr[] = {
      OneByteString(isolate, error->name),
      OneByteString(isolate, error->msg)
    };
    if (err_map->Set(context,
                     Integer::New(isolate, error->value),
                     Array::New(isolate, arr, arraysize(arr))).IsEmpty()) {
      return;
    }
}

The major advantage would probably be that the code isn’t several kilobytes large in this case. No strong feelings about it, though :)

@joyeecheung joyeecheung added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Dec 20, 2018
lib/internal/util.js Show resolved Hide resolved
This removes the `internalBinding('uv')` call from the normal
bootstrap for now, and avoids building `errmap` by default which
expands to a lot of calls into V8.
@joyeecheung
Copy link
Member Author

Rebased and used the static struct array based the suggestion from @addaleax (thanks!), @addaleax @danbev @jasnell @BridgeAR PTAL.

CI: https://ci.nodejs.org/job/node-test-pull-request/19855/

@joyeecheung joyeecheung added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 29, 2018
@joyeecheung
Copy link
Member Author

Landed in c66c073

joyeecheung added a commit that referenced this pull request Dec 29, 2018
This removes the `internalBinding('uv')` call from the normal
bootstrap for now, and avoids building `errmap` by default which
expands to a lot of calls into V8.

PR-URL: #25143
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
targos pushed a commit that referenced this pull request Jan 1, 2019
This removes the `internalBinding('uv')` call from the normal
bootstrap for now, and avoids building `errmap` by default which
expands to a lot of calls into V8.

PR-URL: #25143
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
This removes the `internalBinding('uv')` call from the normal
bootstrap for now, and avoids building `errmap` by default which
expands to a lot of calls into V8.

PR-URL: nodejs#25143
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Jan 16, 2019
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2019
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 pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originated in Node.js core. libuv Issues and PRs related to the libuv dependency or the uv binding. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants