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

events: simplify stack compare function #24744

Closed

Conversation

BridgeAR
Copy link
Member

This simplifies the longestSeqContainedIn() logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

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

This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.
@nodejs-github-bot nodejs-github-bot added the events Issues and PRs related to the events subsystem / EventEmitter. label Nov 30, 2018
lib/events.js Outdated Show resolved Hide resolved
}
if (matches)
return [ len, i, j ];
Copy link
Member

Choose a reason for hiding this comment

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

And for the same reason, returning j might not be used in this specific setup, but it’s part of having this be a more generic function.

Copy link
Member Author

@BridgeAR BridgeAR Nov 30, 2018

Choose a reason for hiding this comment

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

pos translates to the former j but I recommend to change the signature when necessary and not to keep code in here that is currently unused.

lib/events.js Show resolved Hide resolved
@BridgeAR
Copy link
Member Author

BridgeAR commented Dec 2, 2018

Ping @addaleax

@BridgeAR
Copy link
Member Author

BridgeAR commented Dec 5, 2018

This needs some reviews.

@BridgeAR
Copy link
Member Author

BridgeAR commented Dec 5, 2018

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.

Can you do a CITGM run?

// Returns the length and line number of the first sequence of `a` that fully
// appears in `b` with a length of at least 4.
function identicalSequenceRange(a, b) {
for (var i = 0; i < a.length - 3; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

I would cache a.length - 3 in a variable.

Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Member Author

Choose a reason for hiding this comment

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

I expect the value to be constant fold (but I did not check).

Copy link
Member

Choose a reason for hiding this comment

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

a could be quite big, and it used to be slightly faster to cache the value if it's computed.

Copy link
Member Author

Choose a reason for hiding this comment

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

a should normally be small (we currently only use this for stack frames) and this implementation should also be faster than the one before. If it's about performance, I could save a couple comparisons by using a simple for loop instead of indexOf (currently I check until the last entry but the last three entries are not interesting).

@bmeurer do values like these get constant fold?

@BridgeAR
Copy link
Member Author

@mcollina nothing showed up in CITGM (most failures are related due to some windows issues and others to removed V8 functions, the rest is also known).

@BridgeAR
Copy link
Member Author

I know this is nothing important but it would still be great to get some reviews here. This PR is open since 14 days and there was neither a +1, nor a -1.

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

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 14, 2018
@Trott
Copy link
Member

Trott commented Dec 16, 2018

Not strictly required, but it would be great to get another review on this one. @addaleax @bnoordhuis @apapirovski @mscdex (There's not @nodejs/events team, so that list is assembled from very imperfect and superficial use of git shortlog.)

BridgeAR added a commit to BridgeAR/node that referenced this pull request Dec 19, 2018
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: nodejs#24744
Reviewed-By: Matteo Collina <[email protected]>
@BridgeAR
Copy link
Member Author

Landed in a76750b

@BridgeAR BridgeAR closed this Dec 19, 2018
@BridgeAR BridgeAR added the performance Issues and PRs related to the performance of Node.js. label Dec 23, 2018
MylesBorins pushed a commit that referenced this pull request Dec 25, 2018
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: #24744
Reviewed-By: Matteo Collina <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 25, 2018
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: nodejs#24744
Reviewed-By: Matteo Collina <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 17, 2019
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: #24744
Reviewed-By: Matteo Collina <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 28, 2019
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: #24744
Reviewed-By: Matteo Collina <[email protected]>
@BethGriggs BethGriggs mentioned this pull request May 1, 2019
BethGriggs pushed a commit that referenced this pull request May 10, 2019
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: #24744
Reviewed-By: Matteo Collina <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 16, 2019
This simplifies the `longestSeqContainedIn()` logic by checking for
the first identical occurance of at least three frames instead of
the longest one.
It also removes an unused argument.

PR-URL: #24744
Reviewed-By: Matteo Collina <[email protected]>
@BridgeAR BridgeAR deleted the simplify-longestSeqContainedIn branch January 20, 2020 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. events Issues and PRs related to the events subsystem / EventEmitter. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants