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

perf_hooks: fix function wrapped by performance.timerify to work correctly #43330

Merged
merged 2 commits into from
Jun 12, 2022

Conversation

cola119
Copy link
Member

@cola119 cola119 commented Jun 6, 2022

Fixed #40623
(#40625 also fixes this issue but it has been stale and seems not expected to be updated.)

This issue introduced by the refactoring on #37136. The previous implementation was checking whether a function or class is called using the new operator to proxy a function call.

node/src/node_perf.cc

Lines 380 to 393 in 74227bb

bool is_construct_call = args.IsConstructCall();
uint64_t start = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
TRACING_CATEGORY_NODE2(perf, timerify),
*name, *name, start / 1000);
v8::MaybeLocal<Value> ret;
if (is_construct_call) {
ret = fn->NewInstance(context, call_args.length(), call_args.out())
.FromMaybe(Local<Object>());
} else {
ret = fn->Call(context, args.This(), call_args.length(), call_args.out());
}

This PR fixed to align with the previous behavior that a function works the same as if it was called directly.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jun 6, 2022
@cola119 cola119 changed the title pref_hooks: fix function wrapped by timerify to work correctly perf_hooks: fix function wrapped by timerify to work correctly Jun 6, 2022
@cola119 cola119 changed the title perf_hooks: fix function wrapped by timerify to work correctly perf_hooks: fix function wrapped by performance.timerify to work correctly Jun 6, 2022
@cola119

This comment was marked as resolved.

@RaisinTen RaisinTen added perf_hooks Issues and PRs related to the implementation of the Performance Timing API. and removed util Issues and PRs related to the built-in util module. labels Jun 6, 2022
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 7, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 7, 2022
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 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 Jun 12, 2022
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 12, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/43330
✔  Done loading data for nodejs/node/pull/43330
----------------------------------- PR info ------------------------------------
Title      perf_hooks: fix function wrapped by performance.timerify to work correctly (#43330)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     cola119:issue-40623 -> nodejs:master
Labels     c++, author ready, perf_hooks, needs-ci, commit-queue-squash
Commits    2
 - perf_hooks: fix function wrapped by timerify to work correctly
 - fixup! perf_hooks: fix function wrapped by timerify to work correctly
Committers 2
 - cola119 
 - GitHub 
PR-URL: https://github.com/nodejs/node/pull/43330
Reviewed-By: Antoine du Hamel 
Reviewed-By: Darshan Sen 
Reviewed-By: Minwoo Jung 
Reviewed-By: James M Snell 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/43330
Reviewed-By: Antoine du Hamel 
Reviewed-By: Darshan Sen 
Reviewed-By: Minwoo Jung 
Reviewed-By: James M Snell 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Mon, 06 Jun 2022 14:18:45 GMT
   ✔  Approvals: 4
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/43330#pullrequestreview-998895212
   ✔  - Darshan Sen (@RaisinTen) (TSC): https://github.com/nodejs/node/pull/43330#pullrequestreview-999103530
   ✔  - Minwoo Jung (@JungMinu): https://github.com/nodejs/node/pull/43330#pullrequestreview-1001101980
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/43330#pullrequestreview-1003513143
   ✖  Last GitHub CI failed
   ℹ  Last Full PR CI on 2022-06-08T04:36:30Z: https://ci.nodejs.org/job/node-test-pull-request/44403/
- Querying data for job/node-test-pull-request/44403/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/2483034882

@aduh95 aduh95 merged commit 8d5a3e3 into nodejs:master Jun 12, 2022
@aduh95
Copy link
Contributor

aduh95 commented Jun 12, 2022

Landed in 8d5a3e3

italojs pushed a commit to italojs/node that referenced this pull request Jun 12, 2022
PR-URL: nodejs#43330
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Jun 13, 2022
PR-URL: #43330
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@danielleadams danielleadams mentioned this pull request Jun 13, 2022
danielleadams pushed a commit that referenced this pull request Jun 13, 2022
PR-URL: #43330
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #43330
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #43330
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#43330
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
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. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed An error occurred while landing this 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. needs-ci PRs that need a full CI run. perf_hooks Issues and PRs related to the implementation of the Performance Timing API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

performance.timerify doesn't return wrapped function's return value
6 participants