Skip to content

Conversation

@thefourtheye
Copy link
Contributor

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

lib src test

Description of change

Make sure constants object and all the nested objects don't inherit
from Object.prototype but from null.

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. process Issues and PRs related to the process subsystem. labels Dec 26, 2016
@addaleaxaddaleax added lib / src Issues and PRs related to general changes in the lib or src directory. semver-major PRs that contain breaking changes and should be released in the next major version. labels Dec 26, 2016
lib/fs.js Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I think these have a small performance impact, maybe Object.prototype.hasOwnProperty.call is better for all of these?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

As constants inherit from null, will the performance implication still be applicable?

Copy link
Member

Choose a reason for hiding this comment

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

Performance of the in operator has recently been optimized in V8 (in 5.2).

Copy link
Contributor

@mscdexmscdexDec 26, 2016

Choose a reason for hiding this comment

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

@targos It's still quite slow though in master (V8 5.4). I recently swapped usage of in with a simpler undefined check and saw a ~50% improvement.

@thefourtheye I would just do an undefined check (constants.O_SYMLINK !== undefined) instead of in. It should still work fine.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done! I changed them to !== undefined.

@targos
Copy link
Member

What do we gain from this change?

@thefourtheye
Copy link
ContributorAuthor

@targos Lookup should be comparatively faster and problems because of accidental accessing of inherited properties will be avoided, like in #10423

@thefourtheyethefourtheyeforce-pushed the make-constants-inherit-from-null branch from 11a0b88 to 8638f31CompareDecember 26, 2016 18:58
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you capitalize "make" please.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ack.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you name this with camelCase please.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ack.

@thefourtheyethefourtheyeforce-pushed the make-constants-inherit-from-null branch from 8638f31 to aaf7165CompareDecember 26, 2016 19:18
@mscdex
Copy link
Contributor

Copy link
Contributor

@Fishrock123Fishrock123 left a comment

Choose a reason for hiding this comment

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

LGTM for a major (if it works, ci)

@mscdex
Copy link
Contributor

LGTM

@jasnell
Copy link
Member

I'm wondering if a similar semver-major change should not be made to the docs-only deprecated require('constants')

@thefourtheye
Copy link
ContributorAuthor

@jasnell Do you mean the object returned by require('constants') should also inherit from null?

@thefourtheyethefourtheyeforce-pushed the make-constants-inherit-from-null branch from aaf7165 to 002ce78CompareJanuary 3, 2017 18:18
Make sure `constants` object and all the nested objects don't inherit from `Object.prototype` but from `null`.
@thefourtheyethefourtheyeforce-pushed the make-constants-inherit-from-null branch from 002ce78 to 3a75d7cCompareJanuary 3, 2017 18:19
@jasnell
Copy link
Member

@thefourtheye ... yes, that's what I'm thinking. We could choose to leave it untouched but for consistency it may make sense

@thefourtheye
Copy link
ContributorAuthor

@jasnell I just tried that and it affects graceful-fs, https://github.com/isaacs/node-graceful-fs/blob/v4.1.11/polyfills.js#L31 :'(

@jasnell
Copy link
Member

Boo. Ok, I'd leave it as is then.

@jasnell
Copy link
Member

@thefourtheye
Copy link
ContributorAuthor

cc @nodejs/ctc as this is a major change.

@thefourtheye
Copy link
ContributorAuthor

Yet another CI Run to BUMP https://ci.nodejs.org/job/node-test-pull-request/6372/

@jasnell
Copy link
Member

@thefourtheye ... this should be good to go!

@thefourtheye
Copy link
ContributorAuthor

@jasnell Thanks :-) I would be comfortable if I get a green CITGM as well, as this is a major change. I'll try to spend sometime this week to fix it.

@thefourtheye
Copy link
ContributorAuthor

@jasnell
Copy link
Member

CITGM and CI both were good. Landing.

jasnell pushed a commit that referenced this pull request Mar 22, 2017
Make sure `constants` object and all the nested objects don't inherit from `Object.prototype` but from `null`. PR-URL: #10458 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]>
@jasnell
Copy link
Member

Landed in caf9ae7

@jasnelljasnell closed this Mar 22, 2017
@thefourtheyethefourtheye deleted the make-constants-inherit-from-null branch April 2, 2017 07:17
@jasnelljasnell mentioned this pull request Apr 4, 2017
Sign up for freeto 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++.fsIssues and PRs related to the fs subsystem / file system.lib / srcIssues and PRs related to general changes in the lib or src directory.processIssues and PRs related to the process subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@thefourtheye@targos@mscdex@jasnell@addaleax@Fishrock123@cjihrig@nodejs-github-bot