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

v8: use AliasedBuffers for passing heap statistics around #32929

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

Instead of holding shared pointers to ArrayBuffers, simplify
the code by using AliasedBuffers directly which allows the
binding to own the buffers.

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

Instead of holding shared pointers to ArrayBuffers, simplify
the code by using AliasedBuffers directly which allows the
binding to own the buffers.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. v8 engine Issues and PRs related to the V8 dependency. labels Apr 19, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@mscdex
Copy link
Contributor

mscdex commented Apr 19, 2020

This seems to cause a performance regression for getHeapSpaceStatistics() specifically:

                                                          confidence improvement accuracy (*)   (**)   (***)
v8/get-stats.js n=1000000 method='getHeapSpaceStatistics'        ***    -12.75 %       ±2.36% ±3.14%  ±4.09%
v8/get-stats.js n=1000000 method='getHeapStatistics'                     -0.05 %       ±5.79% ±7.72% ±10.07%

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM but I've been thinking strongly about moving things away from AliasedBuffer to the new AliasedStruct to give us a bit more natural way of interacting with the data on the native side.

For instance, instead of having to use buffer[idx] = val on the native side, we'd have something more like buffer.foo = val

@joyeecheung
Copy link
Member Author

@mscdex yes, the performance regression is caused by more calls into the C++ in getHeapSpaceStatistics() - though this is unlikely to be on any hot code path, so I think in this case the simplicity of the code is more important.

@jasnell Thanks for the heads up, it seems #32778 landed fairly recently. It seems to make more sense than the current homogenous array-based approach to me, though I guess we can make the transition incrementally :)

@mscdex
Copy link
Contributor

mscdex commented Apr 20, 2020

Perhaps we should remove benchmark/v8/get-stats.js then?

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2020
@nodejs-github-bot
Copy link
Collaborator

addaleax pushed a commit that referenced this pull request Apr 28, 2020
Instead of holding shared pointers to ArrayBuffers, simplify
the code by using AliasedBuffers directly which allows the
binding to own the buffers.

PR-URL: #32929
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@addaleax
Copy link
Member

Landed in aa9708e

@addaleax addaleax closed this Apr 28, 2020
targos pushed a commit that referenced this pull request May 4, 2020
Instead of holding shared pointers to ArrayBuffers, simplify
the code by using AliasedBuffers directly which allows the
binding to own the buffers.

PR-URL: #32929
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@targos targos mentioned this pull request May 4, 2020
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++. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants