Skip to content

Conversation

gabrielschulhof
Copy link
Contributor

@gabrielschulhof gabrielschulhof commented Jun 13, 2023

Implement defining properties via V8's
v8::Object::CreateDataProperty(), which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: #45905

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/node-api

@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. node-api Issues and PRs related to the Node-API. labels Jun 13, 2023
@gabrielschulhof gabrielschulhof added performance Issues and PRs related to the performance of Node.js. and removed c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Jun 13, 2023
@gabrielschulhof gabrielschulhof force-pushed the 45905-object-creation-speedup branch 2 times, most recently from e9a4032 to d8299a4 Compare June 13, 2023 04:56
@gabrielschulhof
Copy link
Contributor Author

                                                      confidence improvement accuracy (*)   (**)  (***)
napi/define_properties implem='runFastPath' n=5000000        ***     36.49 %       ±3.13% ±4.21% ±5.56%
napi/define_properties implem='runSlowPath' n=5000000          *     -2.82 %       ±2.53% ±3.39% ±4.43%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 2 comparisons, you can thus expect the following amount of false-positive results:
  0.10 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.02 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

@gabrielschulhof gabrielschulhof force-pushed the 45905-object-creation-speedup branch from d8299a4 to 9e08c8b Compare June 13, 2023 14:36
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: nodejs#45905
Signed-off-by: Gabriel Schulhof <[email protected]>
@gabrielschulhof gabrielschulhof force-pushed the 45905-object-creation-speedup branch from 9e08c8b to 4049162 Compare June 14, 2023 05:10
@gabrielschulhof gabrielschulhof added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 14, 2023
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator


auto define_maybe =
obj->DefineProperty(context, property_name, descriptor);
defined_successfully = define_maybe.FromMaybe(false);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should distinguish the state that the DefineProperty operation is failed (e.g. when the object is frozen) or the DefineProperty operation is throwing (e.g. a throwing Proxy handler defineProperty) and returning a different napi_status. As this behavior is not introduced in this PR, I'll create a follow-up PR to do so.

gabrielschulhof added a commit that referenced this pull request Jun 16, 2023
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: #45905
Signed-off-by: Gabriel Schulhof <[email protected]>
PR-URL: #48440
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
@gabrielschulhof
Copy link
Contributor Author

Landed in 3c35cd4.

RafaelGSS pushed a commit that referenced this pull request Jul 3, 2023
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: #45905
Signed-off-by: Gabriel Schulhof <[email protected]>
PR-URL: #48440
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Jul 3, 2023
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: nodejs#45905
Signed-off-by: Gabriel Schulhof <[email protected]>
PR-URL: nodejs#48440
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: nodejs#45905
Signed-off-by: Gabriel Schulhof <[email protected]>
PR-URL: nodejs#48440
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
ruyadorno pushed a commit that referenced this pull request Sep 8, 2023
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: #45905
Signed-off-by: Gabriel Schulhof <[email protected]>
PR-URL: #48440
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Sep 8, 2023
ruyadorno pushed a commit that referenced this pull request Sep 13, 2023
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: #45905
Signed-off-by: Gabriel Schulhof <[email protected]>
PR-URL: #48440
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Sign up for free to 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++. node-api Issues and PRs related to the Node-API. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants