GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: improve for-loop readability in _http_outgoing.js by gengjiawen · Pull Request #26408 · nodejs/node

Conversation

@gengjiawen

@gengjiawen gengjiawen commented Mar 3, 2019

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added the http Issues and PRs related to the http subsystem. label Mar 3, 2019
@gengjiawen
gengjiawen force-pushed the forloop_http_outgoing branch from efd378c to 4b05938 Compare March 3, 2019 05:01
gengjiawen
gengjiawen commented Mar 3, 2019
View reviewed changes
Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gengjiawen
gengjiawen force-pushed the forloop_http_outgoing branch from 4b05938 to bd731a0 Compare March 3, 2019 07:46
BridgeAR
BridgeAR reviewed Mar 3, 2019
View reviewed changes
Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR changed the title lib: improve for-loop readability in _http_outgoing.js http: improve for-loop readability in _http_outgoing.js Mar 5, 2019
@BridgeAR

BridgeAR commented Mar 5, 2019

Copy link
Copy Markdown
Member

Object.values() has not been improvement significantly since the last time I checked: https://bugs.chromium.org/p/v8/issues/detail?id=8071

If we change something, I suggest to use Object.keys() instead of in.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gengjiawen
gengjiawen force-pushed the forloop_http_outgoing branch from bd731a0 to 781024d Compare March 6, 2019 14:12
@gengjiawen

gengjiawen commented Mar 6, 2019

Copy link
Copy Markdown
Member Author

@BridgeAR Can you review this again ? thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR
BridgeAR approved these changes Mar 6, 2019
View reviewed changes

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I would still check for if (headers != null) {. That way if there are no headers, we spare two extra checks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gengjiawen

gengjiawen commented Mar 6, 2019

Copy link
Copy Markdown
Member Author

@BridgeAR Good point. I will add it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gengjiawen
lib: improve for-loop readability in _http_outgoing.js
9c0359e
@gengjiawen
gengjiawen force-pushed the forloop_http_outgoing branch from 781024d to 9c0359e Compare March 6, 2019 15:21
@gengjiawen

gengjiawen commented Mar 6, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@BridgeAR Done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented Mar 6, 2019

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Mar 6, 2019
@BridgeAR
BridgeAR requested review from lpinca and mcollina March 6, 2019 23:34
mcollina
mcollina requested changes Mar 7, 2019
View reviewed changes

@mcollina mcollina left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is a very sensitive hot path. I’m -1 to any changes that do not improve our benchmarks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lpinca
lpinca approved these changes Mar 7, 2019
View reviewed changes
@lpinca

lpinca commented Mar 7, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I think this has 0 impact on performance. Will run a benchmark CI to verify.

BridgeAR and gengjiawen reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Mar 7, 2019

Copy link
Copy Markdown
Member

@lpinca I'm pretty sure it has some impact. for-of  loops are slower than for(;;).
https://github.com/nodejs/node/pull/26408/files#diff-286202fdbdd74ede6f5f5334b6176b5cR306.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lpinca

lpinca commented Mar 7, 2019

Copy link
Copy Markdown
Member

https://jsperf.com/for-of-vs-for-loop they seem to be on par on Chrome 72.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lpinca

lpinca commented Mar 7, 2019

Copy link
Copy Markdown
Member

If this is a problem for 10.x 8.x and 6.x we can add the required "do not land" labels.

gengjiawen, mcollina, and BridgeAR reacted with heart emoji
All reactions
  • ❤️ 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Mar 7, 2019

Copy link
Copy Markdown
Contributor

https://jsperf.com/for-of-vs-for-loop they seem to be on par on Chrome 72.

The for-loop case in that benchmark consistently shows it being faster for me with Chrome 72

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gengjiawen

gengjiawen commented Mar 7, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

On chrome 72, for-of is faster than for-loop.
image

Update:
sometimes, the perf is very near
image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina added dont-land-on-v6.x labels Mar 7, 2019
@Rednickle Rednickle mentioned this pull request Mar 8, 2021
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 Rednickle/node-1#15
Open
This was referenced Mar 11, 2021
[Snyk] Fix for 6 vulnerabilities Dmarch28/node#8
Open
[Snyk] Fix for 6 vulnerabilities Dmarch28/node#9
Open
This was referenced May 25, 2021
[Snyk] Security upgrade gatsby-plugin-sharp from 2.6.24 to 2.6.31 Dmarch28/node#21
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.6.24 to 2.6.31 Dmarch28/node#22
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.2.13 to 2.6.31 kissofire/node#35
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 sitedata/node#25
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.2.13 to 2.6.31 meghasfdc/node#35
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 ron-a20/node#33
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.6.24 to 2.6.31 baby636/node#10
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 Rednickle/node-1#22
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 aliceUnhinged613/node#25
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 137717unity/node#26
Open
This was referenced Apr 7, 2022
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 ron-a20/node#61
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 Rednickle/node-1#47
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 137717unity/node#52
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 aliceUnhinged613/node#53
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.6.24 to 2.6.31 Dmarch28/node#54
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.6.24 to 2.6.31 baby636/node#49
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 molllyn1/node#43
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 wedataintelligence/node#28
Open
[Snyk] Security upgrade gatsby-plugin-sharp from 2.3.10 to 2.6.31 turkdevops/node#364
Closed
@snyk-bot snyk-bot mentioned this pull request Jan 30, 2023
[Snyk] Fix for 1 vulnerabilities aliceUnhinged613/node#89
Open
@wedataintelligence wedataintelligence mentioned this pull request Jan 30, 2023
[Snyk] Fix for 1 vulnerabilities wedataintelligence/node#73
Open
@snyk-bot snyk-bot mentioned this pull request Jan 30, 2023
[Snyk] Fix for 1 vulnerabilities kissofire/node#94
Open
@molllyn1 molllyn1 mentioned this pull request Jan 31, 2023
[Snyk] Fix for 1 vulnerabilities molllyn1/node#76
Open
@snyk-bot snyk-bot mentioned this pull request Jan 31, 2023
[Snyk] Fix for 1 vulnerabilities 137717unity/node#93
Open
@baby636 baby636 mentioned this pull request Jan 31, 2023
[Snyk] Fix for 1 vulnerabilities baby636/node#88
Open
This was referenced Jan 31, 2023
[Snyk] Fix for 1 vulnerabilities ron-a20/node#93
Open
[Snyk] Fix for 1 vulnerabilities Rednickle/node-1#70
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@lpinca lpinca lpinca approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
+1 more reviewer
@mscdex mscdex mscdex left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. http Issues and PRs related to the http subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@gengjiawen @BridgeAR @lpinca @mcollina @mscdex @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.