Skip to content

lib: refactor some lib/internals - #11406

Closed
jasnell wants to merge 4 commits into
nodejs:masterfrom
jasnell:refactor-internals
Closed

lib: refactor some lib/internals#11406
jasnell wants to merge 4 commits into
nodejs:masterfrom
jasnell:refactor-internals

Conversation

@jasnell

Copy link
Copy Markdown
Member

Some light refactoring of internals/*.js

  • For linkedlist and freelist, this yields about a 5% perf improvement in general
  • Consistent use of the module.exports = {} pattern, with module.exports = {} at the end.

(do not squash commits)

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

lib/internal

@nodejs-github-botnodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Feb 15, 2017
Comment threadlib/internal/freelist.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR, but perhaps this can be simplified since http is the only user of FreeList and we'd know how what arguments to pass on to the constructor. I'm not sure if adding new would help (allowing us to avoid an instanceof check in the constructor if possible) more than it might hurt (e.g. if stack traces would change with new constructor(..)).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Worth playing around with. I would also note that I had attempted to replace this use of arguments with ...args, but found that in the case there are no arguments passed to the alloc(), it caused a whopping 48% slowdown. Definitely something we'll need to keep in mind.

Comment threadlib/internal/net.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unintended?

Comment threadlib/internal/freelist.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Naming own properties of instances constructor is kind of confusing, maybe you could change that while you’re here?

Comment threadlib/internal/socket_list.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Likewise, it would be awesome if we could change this during the refactor (here and in the other parts of the file this PR touches).

@jasnell

Copy link
Copy Markdown
MemberAuthor

@addaleax@mscdex ... updated!

@jasnelljasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Feb 16, 2017
@jasnell

Copy link
Copy Markdown
MemberAuthor

semver-major because an error message is changed.

@jasnell

Copy link
Copy Markdown
MemberAuthor

jasnell added a commit that referenced this pull request Feb 22, 2017
PR-URL: #11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
jasnell added a commit that referenced this pull request Feb 22, 2017
PR-URL: #11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
jasnell added a commit that referenced this pull request Feb 22, 2017
PR-URL: #11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
jasnell added a commit that referenced this pull request Feb 22, 2017
Switch to using the more efficient module.exports = {}
where possible.
PR-URL: #11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@jasnell

Copy link
Copy Markdown
MemberAuthor

Landed in d61a511...62e9609

@jasnelljasnell closed this Feb 22, 2017
@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

lib / srcIssues and PRs related to general changes in the lib or src directory.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.

5 participants

@jasnell@mscdex@addaleax@targos@nodejs-github-bot