Skip to content

src: implement --trace-promises - #50899

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
joyeecheung:trace-promises
Dec 5, 2023
Merged

src: implement --trace-promises#50899
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
joyeecheung:trace-promises

Conversation

@joyeecheung

Copy link
Copy Markdown
Member

This patch implements a debugging flag that dumps the current stack trace when a promise is created or resolved. To reduce noise we ignore before and after events (as the execution is less interesting) and use the per-isolate hook to avoid extra JS frames. This flag can assist work in reducing unnecessary promise overhead.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Nov 24, 2023

@GeoffreyBoothGeoffreyBooth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will be very useful! Just needs docs.

@anonriganonrig added the notable-change PRs with changes that should be highlighted in changelogs. label Nov 24, 2023
@github-actions

Copy link
Copy Markdown
Contributor

The notable-changePRs with changes that should be highlighted in changelogs. label has been added by @anonrig.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@anonriganonrig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you update docs as well?

Comment threadsrc/env.cc Outdated
@joyeecheung

joyeecheung commented Nov 24, 2023

Copy link
Copy Markdown
MemberAuthor

This will be very useful! Just needs docs.

I think this should be a core developer debugging flag (we have several of those, like --verify-base-objects and --inspect-brk-node) so we should avoid documenting it. At least for now, lest some user depends on it. We can consider documenting it later when it's used a bit more internally. (I am not even sure if this is free of bugs, but as far as I've tested it works well enough).

@joyeecheungjoyeecheung removed the notable-change PRs with changes that should be highlighted in changelogs. label Nov 24, 2023
@theanarkh

Copy link
Copy Markdown
Contributor

Does SetPromiseHook have any effect on performance ?

@joyeecheung

joyeecheung commented Nov 25, 2023

Copy link
Copy Markdown
MemberAuthor

Does SetPromiseHook have any effect on performance ?

I think the cost can be non-trivial, depending on how promise-heavy the use case is, although it’s just a debugging flag so it’s not supposed to be turned on in any case that care about performance.

This patch implements a debugging flag that dumps the current
stack trace when a promise is created or resolved. To reduce
noise we ignore before and after events (as the execution is
less interesting) and use the per-isolate hook to avoid extra
JS frames. This flag can assist work in reducing unnecessary
promise overhead.
@joyeecheungjoyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 27, 2023
@joyeecheung

Copy link
Copy Markdown
MemberAuthor

Removed it from the tests because we are intentionally not documenting it for now.

@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 27, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@joyeecheungjoyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 27, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 27, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@benjamingr

Copy link
Copy Markdown
Member

Does SetPromiseHook have any effect on performance ?

Pretty significant but being set in C++ helps

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@joyeecheungjoyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 1, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 1, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@joyeecheungjoyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Dec 5, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 5, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 1e31a01 into nodejs:mainDec 5, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1e31a01

RafaelGSS pushed a commit that referenced this pull request Dec 15, 2023
This patch implements a debugging flag that dumps the current
stack trace when a promise is created or resolved. To reduce
noise we ignore before and after events (as the execution is
less interesting) and use the per-isolate hook to avoid extra
JS frames. This flag can assist work in reducing unnecessary
promise overhead.
PR-URL: #50899
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@RafaelGSSRafaelGSS mentioned this pull request Dec 15, 2023
@DanKaplanSES

DanKaplanSES commented Mar 5, 2024

Copy link
Copy Markdown
Contributor

FYI, I created a feature request for a "promise dump" of a currently running program. I thought I'd mention it here because it might be another useful dev tool like --trace-promises, and to me it felt related. I'd love to hear others' thoughts.

richardlau pushed a commit that referenced this pull request Mar 25, 2024
This patch implements a debugging flag that dumps the current
stack trace when a promise is created or resolved. To reduce
noise we ignore before and after events (as the execution is
less interesting) and use the per-isolate hook to avoid extra
JS frames. This flag can assist work in reducing unnecessary
promise overhead.
PR-URL: #50899
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@richardlaurichardlau mentioned this pull request Mar 25, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.lib / srcIssues and PRs related to general changes in the lib or src directory.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@joyeecheung@nodejs-github-bot@theanarkh@benjamingr@DanKaplanSES@GeoffreyBooth@anonrig@legendecas@H4ad