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 — src: fix performance regression in node_file.cc by bnoordhuis · Pull Request #31343 · nodejs/node

Conversation

@bnoordhuis

@bnoordhuis bnoordhuis commented Jan 13, 2020

Copy link
Copy Markdown
Member

Commits dcb6929, 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.

Sorry, something went wrong.

Uh oh!

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

bricss and himself65 reacted with thumbs up emoji hybrist reacted with hooray emoji
All reactions
  • 👍 2 reactions
  • 🎉 1 reaction
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. labels Jan 13, 2020
@nodejs-github-bot

nodejs-github-bot commented Jan 13, 2020

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

cjihrig
cjihrig approved these changes Jan 13, 2020
View reviewed changes
guybedford
guybedford approved these changes Jan 13, 2020
View reviewed changes

@guybedford guybedford left a comment

Copy link
Copy Markdown
Contributor

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.

Great to see this, thanks.

Sorry, something went wrong.

Uh oh!

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

All reactions
devnexen
devnexen approved these changes Jan 13, 2020
View reviewed changes
devsnek
devsnek reviewed Jan 13, 2020
View reviewed changes
Comment thread src/node_file.cc Outdated

@devsnek devsnek Jan 13, 2020

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.

could you use if statements here to avoid goto?

Sorry, something went wrong.

Uh oh!

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

All reactions

@bnoordhuis bnoordhuis Jan 14, 2020

Copy link
Copy Markdown
Member Author

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.

No, for two reasons:

  1. Aesthetic. It keeps the level of indent small.
  2. Performance. g++ 9.2.1 at -O3 doesn't move the block out of the way. The goto keeps the inner loop at around 80 bytes:
Details
    10ec:       80 f9 22                cmp    $0x22,%cl
    10ef:       74 1f                   je     1110 <main+0x70>
    10f1:       80 f9 5c                cmp    $0x5c,%cl
    10f4:       75 44                   jne    113a <main+0x9a>
    10f6:       48 39 fa                cmp    %rdi,%rdx
    10f9:       73 65                   jae    1160 <main+0xc0>
    10fb:       0f b6 4e 01             movzbl 0x1(%rsi),%ecx
    10ff:       80 f9 22                cmp    $0x22,%cl
    1102:       74 7c                   je     1180 <main+0xe0>
    1104:       48 89 d6                mov    %rdx,%rsi
    1107:       48 8d 56 01             lea    0x1(%rsi),%rdx
    110b:       80 f9 22                cmp    $0x22,%cl
    110e:       75 e1                   jne    10f1 <main+0x51>
    1110:       49 8d 48 08             lea    0x8(%r8),%rcx
    1114:       49 89 10                mov    %rdx,(%r8)
    1117:       4c 39 c9                cmp    %r9,%rcx
    111a:       72 34                   jb     1150 <main+0xb0>
    111c:       48 8b 34 24             mov    (%rsp),%rsi
    1120:       48 89 f1                mov    %rsi,%rcx
    1123:       48 f7 d1                not    %rcx
    1126:       48 03 4c 24 08          add    0x8(%rsp),%rcx
    112b:       48 83 f9 04             cmp    $0x4,%rcx
    112f:       74 5f                   je     1190 <main+0xf0>
    1131:       4d 89 d0                mov    %r10,%r8
    1134:       48 83 f9 07             cmp    $0x7,%rcx
    1138:       74 76                   je     11b0 <main+0x110>
    113a:       48 39 fa                cmp    %rdi,%rdx
    113d:       73 21                   jae    1160 <main+0xc0>
    113f:       0f b6 0a                movzbl (%rdx),%ecx
    1142:       48 89 d6                mov    %rdx,%rsi
    1145:       eb a1                   jmp    10e8 <main+0x48>

(-O3 is kind of disappointing; with -Os it fits in a single cache line.)

I'll add a comment explaining why it's there.

Sorry, something went wrong.

Uh oh!

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

All reactions
addaleax
addaleax approved these changes Jan 13, 2020
View reviewed changes

@addaleax addaleax 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.

Code LGTM but the commit message should be changed to something that’s a) descriptive of what this commit actually does and b) not a wordplay on a right-wing slogan before or during merging.

Sorry, something went wrong.

Uh oh!

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

jasnell, devsnek, bnb, and ljharb reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
ryanmurakami
ryanmurakami previously requested changes Jan 13, 2020
View reviewed changes

@ryanmurakami ryanmurakami left a comment

Copy link
Copy Markdown
Contributor

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.

@bnoordhuis The Moderation Team is requesting that you change the commit message and pull request title. The Moderation Team believes the similarities to an American politician's campaign slogan is not in line with the Code of Conduct's guide to use "welcoming and inclusive language". The Moderation Team is happy to provide external references should you need them.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bnoordhuis bnoordhuis changed the title src: make InternalModuleReadJSON great again src: make InternalModuleReadJSON linear again Jan 14, 2020
@bnoordhuis
src: make InternalModuleReadJSON() linear again
da6b66a
Commits dcb6929, 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.
@bnoordhuis
bnoordhuis force-pushed the fix31340 branch from e8ed86b to da6b66a Compare January 14, 2020 10:49
@bnoordhuis
bnoordhuis dismissed ryanmurakami’s stale review January 14, 2020 10:49

obsolete

@bnoordhuis

bnoordhuis commented Jan 14, 2020

Copy link
Copy Markdown
Member Author

not a wordplay on a right-wing slogan before or during merging.

A play on a left-wing slogan would've been okay then? I've changed it to something more boring, PTAL.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Trott

Trott commented Jan 15, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

not a wordplay on a right-wing slogan before or during merging.

A play on a left-wing slogan would've been okay then?

The phrase is one that provokes strong reactions. I think it is reasonable to request that it be changed in a situation like this where using the phrase is unnecessary.

But yes, the fact that the slogan is right-wing is not really the problem, per se. Had it been a play on "Read my lips: no new taxes", I don't think it would generate the same reaction.

FWIW, I can definitely think of a few left-wing slogans that would be problematic.

I've changed it to something more boring, PTAL.

Let's make it even more boring and remove all vestiges of the wordplay. src: fix performance regression in node_file.cc or maybe src: fix performance regression in InternalModuleReadJSON?

ChALkeR and addaleax 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.

Trott
Trott approved these changes Jan 15, 2020
View reviewed changes
hybrist
hybrist approved these changes Jan 15, 2020
View reviewed changes

@hybrist hybrist left a comment

Copy link
Copy Markdown
Contributor

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.

LGTM with updated commit message

Sorry, something went wrong.

Uh oh!

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

All reactions
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

nodejs-github-bot commented Jan 15, 2020

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

Trott pushed a commit that referenced this pull request Jan 15, 2020
@bnoordhuis @Trott
src: fix performance regression in node_file.cc
6623481
Commits dcb6929, 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.

PR-URL: #31343
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
@Trott

Trott commented Jan 15, 2020

Copy link
Copy Markdown
Member

Landed in 6623481.

I updated the commit message on landing.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Trott Trott closed this Jan 15, 2020
@ljharb ljharb mentioned this pull request Jan 15, 2020
src: fix performance regression in node_file.cc #31340
Closed
@ljharb ljharb changed the title src: make InternalModuleReadJSON linear again src: fix performance regression in node_file.cc Jan 15, 2020
MylesBorins pushed a commit that referenced this pull request Jan 16, 2020
@bnoordhuis @MylesBorins
src: fix performance regression in node_file.cc
83f7b5a
Commits dcb6929, 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.

PR-URL: #31343
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
@codebytere codebytere mentioned this pull request Jan 16, 2020
v13.7.0 proposal #31382
Merged
codebytere pushed a commit that referenced this pull request Mar 14, 2020
@bnoordhuis @codebytere
src: fix performance regression in node_file.cc
23a5339
Commits dcb6929, 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.

PR-URL: #31343
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
codebytere pushed a commit that referenced this pull request Mar 17, 2020
@bnoordhuis @codebytere
src: fix performance regression in node_file.cc
a2f1825
Commits dcb6929, 4396beb and 8a96d05 turned the O(n) scan in
InternalModuleReadJSON() into an O(4n) scan. Fix the performance
regression by turning that into a linear scan again.

PR-URL: #31343
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
@codebytere codebytere mentioned this pull request Mar 17, 2020
v12.16.2 proposal #32313
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hybrist hybrist hybrist approved these changes
@guybedford guybedford guybedford approved these changes
@Trott Trott Trott approved these changes
@addaleax addaleax addaleax approved these changes
@cjihrig cjihrig cjihrig approved these changes
+3 more reviewers
@devsnek devsnek devsnek left review comments
@devnexen devnexen devnexen approved these changes
@ryanmurakami ryanmurakami ryanmurakami 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

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module.

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.

10 participants

@bnoordhuis @nodejs-github-bot @Trott @hybrist @guybedford @ryanmurakami @addaleax @cjihrig @devnexen @devsnek
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 01402503 — 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.