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: move process.binding('performance') to internalBinding #22029

Closed
wants to merge 1 commit into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jul 30, 2018

Migrate process.binding('performance') to internalBinding('performance')

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • 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++. perf_hooks Issues and PRs related to the implementation of the Performance Timing API. test Issues and PRs related to the tests. labels Jul 30, 2018
@jasnell
Copy link
Member Author

jasnell commented Jul 30, 2018

@jdalton
Copy link
Member

jdalton commented Jul 30, 2018

I don't have any experience with process.binding("performance"). Is it primarily used for test?

@TimothyGu
Copy link
Member

@jdalton It's used to power https://nodejs.org/api/perf_hooks.html.

@jdalton
Copy link
Member

jdalton commented Jul 30, 2018

Ah nice! So already exposed in a user-friendly way 🤘

module.exports = {
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
};
module.exports = { internalBinding };
Copy link
Member

Choose a reason for hiding this comment

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

If I am not mistaken this file is now actually obsolete.

Copy link
Member Author

Choose a reason for hiding this comment

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

No it is not. This is the only way internalBinding is accessible by tests

@@ -5,10 +5,5 @@ process.emitWarning(
'tracked by any versioning system or deprecation process.',
'internal/test/binding');

// These exports should be scoped as specifically as possible
// to avoid exposing APIs because even with that warning and
// this file being internal people will still try to abuse it.
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason to switch from the original idea of limiting the set of exports as much as possible here?

Copy link
Member

Choose a reason for hiding this comment

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

This was here for a reason. I'm really kinda -1 on changing it without first exploring alternatives.

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason is to help keep this maintainable. We use process.binding quite a bit in tests and it's far less maintainable to expose each individual property as exports on this object. I understand the reasoning but this approach keeps this test object as simple as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

For instance, process.binding() appears 157 times in test/parallel. Several of those are duplicates, but supporting all of those would mean managing a very large number of exports on internal/test/binding

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @jasnell. I do not see a different way for doing this, could you come up with a different approach @apapirovski?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ping @apapirovski ... there's really not a scalable way of picking and choosing the exports here so if you have a suggested alternative please let me know.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@maclover7 maclover7 added the semver-major PRs that contain breaking changes and should be released in the next major version. label Aug 6, 2018
@maclover7
Copy link
Contributor

maclover7 commented Aug 7, 2018

CITGM (sqlite3 and winston have been flaky as of late): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1487/

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@jasnell
Copy link
Member Author

jasnell commented Aug 7, 2018

Ping @apapirovski again. See #22029 (comment) ^^

@jasnell
Copy link
Member Author

jasnell commented Aug 8, 2018

Given that there's been no follow up on the conversation and there are multiple approvals, I plan to go ahead and land this tomorrow if there are no further objections.

@devsnek
Copy link
Member

devsnek commented Aug 8, 2018

as the person who added that comment about keeping the exports scoped... as we're moving everything to internalBinding it would basically become a flat object of all the different exports of all the different internal bindings. the change here makes sense imo. cc @apapirovski

jasnell added a commit that referenced this pull request Aug 9, 2018
PR-URL: #22029
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@jasnell
Copy link
Member Author

jasnell commented Aug 9, 2018

Landed in 9f5cc1f

@jasnell jasnell closed this Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. perf_hooks Issues and PRs related to the implementation of the Performance Timing API. semver-major PRs that contain breaking changes and should be released in the next major version. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.