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

doc: add explanation why keep var with for loop in async_hooks #30380

Closed
wants to merge 1 commit into from

Conversation

lrecknagel
Copy link
Contributor

@lrecknagel lrecknagel commented Nov 12, 2019

Refs: nceu19-async_hooks

This comment will help contributors to understand why keeping var in some for loop instead changing at to let, as discussed with @mcollina

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Refs: nceu19-async_hooks

This comment will help contributors to understand why keeping var
@nodejs-github-bot nodejs-github-bot added the async_hooks Issues and PRs related to the async hooks subsystem. label Nov 12, 2019
@Trott
Copy link
Member

Trott commented Nov 12, 2019

Welcome, @lrecknagel and thanks for the pull request. I'm guessing this is from a Code + Learn event. I'm not sure the "let inside a loop is much slower than var" thing is true anymore in current V8. /ping @nodejs/v8

@mcollina
Copy link
Member

This is an extremely tight loop in a code path that is hit a lot.
This is still true on Node 10 and it would mean that we would not be able to backport this change.
Given that this is a cosmetic change that might cause issues, I prefer to not change them.

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 jasnell added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Nov 12, 2019
@Trott
Copy link
Member

Trott commented Nov 12, 2019

This is an extremely tight loop in a code path that is hit a lot.
This is still true on Node 10 and it would mean that we would not be able to backport this change.
Given that this is a cosmetic change that might cause issues, I prefer to not change them.

Cool. Let's see if we can get that information into the comment. As it reads now, it could encourage someone to go through and change all let in loops to var throughout core.

@Trott
Copy link
Member

Trott commented Nov 12, 2019

I left two optional suggestions. It will save someone a little bit of git blame archaeology should these lines get moved around, edited, etc. But totally optional. Thanks.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@gireeshpunathil
Copy link
Member

the windows failure sequential/test-inspector-contexts is known as in #30519

the windows failure parallel/test-inspector-wait-for-connection is known as in #30619

the linux containerized failure parallel/test-readline-async-iterators-destroy is reported #30660

gireeshpunathil pushed a commit that referenced this pull request Nov 26, 2019
This comment will help contributors to understand why keeping var
PR-URL: #30380
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@gireeshpunathil
Copy link
Member

landed in 4506991

addaleax pushed a commit that referenced this pull request Nov 30, 2019
This comment will help contributors to understand why keeping var
PR-URL: #30380
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
targos pushed a commit that referenced this pull request Dec 1, 2019
This comment will help contributors to understand why keeping var
PR-URL: #30380
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Dec 3, 2019
@BethGriggs BethGriggs mentioned this pull request Dec 9, 2019
MylesBorins pushed a commit that referenced this pull request Dec 17, 2019
This comment will help contributors to understand why keeping var
PR-URL: #30380
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Dec 23, 2019
@Aschen
Copy link
Contributor

Aschen commented Jul 18, 2022

👋 Just passing by here and I was curious so I ran some benchmarks if anyone is curious about this.

At the time of Node.js 6 it was a real performance gain but nowadays it's almost the same

image

Source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants