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 — doc: add ReflectConstruct to known perf issues by H4ad · Pull Request #50111 · nodejs/node

Conversation

@H4ad

@H4ad H4ad commented Oct 10, 2023

Copy link
Copy Markdown
Member

There are a lot of PRs created initially by nodejs/performance#109 to improve performance issues with this primordial.

Sorry, something went wrong.

Uh oh!

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

All reactions
@H4ad
doc: add ReflectConstruct to known perf issues
2d962e2
@H4ad
H4ad marked this pull request as ready for review October 10, 2023 02:36
@nodejs-github-bot

nodejs-github-bot commented Oct 10, 2023

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/tsc
All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to Node.js documentation. label Oct 10, 2023
@H4ad
fixup! doc: add ReflectConstruct to known perf issues
6551eed
anonrig
anonrig approved these changes Oct 10, 2023
View reviewed changes
benjamingr
benjamingr approved these changes Oct 10, 2023
View reviewed changes

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

FWIW the reason isn't ReflectConstruct per-se it's the usage of anonymous (new) classes each time with it that is the problem. Still I generally agree there be very little cases where it is required.

Sorry, something went wrong.

Uh oh!

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

H4ad reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
aduh95
aduh95 requested changes Oct 10, 2023
View reviewed changes

@aduh95 aduh95 left a comment •
edited
Loading

Uh oh!

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

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.

Yeah I'm not sure it makes sense to list it here, because using Reflect.construct would not be more performant. The list (currently) lists the primordials for which it's faster to call the non-primordial version (e.g., rewriting someArray.push(1) to ArrayPrototypePush(someArray, 1) can lead to a huge perf regression in hot path). I think it makes more sense to either have it as a separate list, or maybe even a different document since it's hardly related to primordials IIUC.

Sorry, something went wrong.

Uh oh!

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

All reactions
@H4ad

H4ad commented Oct 10, 2023

Copy link
Copy Markdown
Member Author

Maybe:

Primordials we should avoid for performance issues

Below are some primordials that we can avoid to be more performant:

  • ReflectConstruct: see linked PRs to nodejs/performance#109
    to learn faster methods.

In general, it's not a problem if you don't have an alternative but sometimes you can avoid it by writing the code in a different way and have less overhead.

All reactions

Sorry, something went wrong.

Uh oh!

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

@aduh95

aduh95 commented Oct 10, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Have measured if Reflect.construct is faster than ReflectConstruct? My understanding is that both perform about the same, correct? If that's the case, you should say so:

ReflectConstruct: we avoid it for the same reason we avoid the non-primordial Reflect.construct, see the issue …

Otherwise it seems not far-fetched this think the reader might conclude that Reflect.construct would be a better alternative for faster code, when it is not.

legendecas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

mcollina
mcollina approved these changes Oct 10, 2023
View reviewed changes

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

lgtm

Sorry, something went wrong.

Uh oh!

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

All reactions
@benjamingr

benjamingr commented Oct 10, 2023

Copy link
Copy Markdown
Member

I agree with @aduh95 's comments. We should avoid Reflect.construct as well - otherwise people might see this and use Reflect.construct instead of ReflectConstruct which isn't the point (which is - they should avoid creating new types of classes inside a function instead of having a shared class like in those issues)

All reactions

Sorry, something went wrong.

Uh oh!

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

@H4ad

H4ad commented Oct 10, 2023

Copy link
Copy Markdown
Member Author

Any recommendations on where I should put this recommendation? Should I write something like #50111 (comment) or close this PR?

All reactions

Sorry, something went wrong.

Uh oh!

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

aymen94
aymen94 approved these changes Oct 18, 2023
View reviewed changes
Uzlopak
Uzlopak reviewed Oct 18, 2023
View reviewed changes
Comment thread doc/contributing/primordials.md Resolved

Uh oh!

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

@H4ad @Uzlopak
fixup! doc: add ReflectConstruct to known perf issues
614c67b
Co-authored-by: Uzlopak <[email protected]>
@H4ad
H4ad requested a review from aduh95 October 18, 2023 14:52
aduh95
aduh95 approved these changes Oct 18, 2023
View reviewed changes
Comment thread doc/contributing/primordials.md Resolved

Uh oh!

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

@H4ad @aduh95
fixup! doc: add ReflectConstruct to known perf issues
f13cac8
Co-authored-by: Antoine du Hamel <[email protected]>
aduh95
aduh95 reviewed Oct 18, 2023
View reviewed changes
Comment thread doc/contributing/primordials.md Resolved

Uh oh!

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

@H4ad
fixup! doc: add ReflectConstruct to known perf issues
b6e6d62
aduh95
aduh95 approved these changes Oct 18, 2023
View reviewed changes
@aduh95 aduh95 added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Oct 18, 2023
Uzlopak
Uzlopak reviewed Oct 18, 2023
View reviewed changes
Comment thread doc/contributing/primordials.md
@@ -124,7 +124,7 @@ performance of code in Node.js.
* `SafePromisePrototypeFinally`: use `try {} finally {}` block instead.
* `ReflectConstruct`: Also affects `Reflect.construct`.
`ReflectConstruct` creates new types of classes inside functions.

@Uzlopak Uzlopak Oct 18, 2023

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.

I know I am nitpicking myself.

Maybe should be "at runtime" and not "inside functions".

Sorry.

Sorry, something went wrong.

Uh oh!

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

All reactions

@H4ad H4ad Oct 18, 2023 •
edited
Loading

Uh oh!

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

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.

What about:

ReflectConstruct instantiates a class with a custom constructor.

Sorry, something went wrong.

Uh oh!

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

All reactions
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 18, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 340b9a8 into nodejs:main Oct 18, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 18, 2023

Copy link
Copy Markdown
Collaborator

Landed in 340b9a8

All reactions

Sorry, something went wrong.

Uh oh!

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

@H4ad
H4ad deleted the doc/reflect-construct-known-perf-issue branch October 18, 2023 19:32
targos pushed a commit that referenced this pull request Oct 23, 2023
@H4ad @targos
doc: add ReflectConstruct to known perf issues
dacee4d
PR-URL: #50111
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@targos targos mentioned this pull request Oct 23, 2023
v21.1.0 release proposal #50335
Merged
targos pushed a commit that referenced this pull request Nov 11, 2023
@H4ad @targos
doc: add ReflectConstruct to known perf issues
d4659e2
PR-URL: #50111
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@targos targos mentioned this pull request Nov 12, 2023
v20.10.0 release proposal #50682
Merged
@juanarbol juanarbol mentioned this pull request Dec 6, 2023
2023-12-06, N|Solid v5.0.1 Iron Release nodesource/nsolid#41
Merged
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
@benjamingr benjamingr benjamingr approved these changes
@anonrig anonrig anonrig approved these changes
@aduh95 aduh95 aduh95 approved these changes
+2 more reviewers
@Uzlopak Uzlopak Uzlopak left review comments
@aymen94 aymen94 aymen94 approved these changes
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. commit-queue-squash PRs the Commit Queue should land as one squashed commit. doc Issues and PRs related to Node.js documentation.

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.

8 participants

@H4ad @nodejs-github-bot @aduh95 @benjamingr @mcollina @anonrig @Uzlopak @aymen94
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.