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

src: do not cache NumberOfHeapSpaces() globally #20971

Closed
wants to merge 2 commits into from

Conversation

addaleax
Copy link
Member

While NumberOfHeapSpaces() currently returns a constant value,
that is not strictly guaranteed by the V8 API as far as I can tell.
Therefore, caching it globally does not seem appropriate.

(The motivation here is that this squelches warnings which are
produced by concurrency debugging tooling due to the apparent
race conditions when accessing the global variable.)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes (presumably)
  • commit message follows commit guidelines

While `NumberOfHeapSpaces()` currently returns a constant value,
that is not strictly guaranteed by the V8 API as far as I can tell.
Therefore, caching it globally does not seem appropriate.

(The motivation here is that this squelches warnings which are
produced by concurrency debugging tooling due to the apparent
race conditions when accessing the global variable.)
@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 May 25, 2018
src/node_v8.cc Outdated
@@ -101,7 +98,7 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo<Value>& args) {
Isolate* const isolate = env->isolate();
double* buffer = env->heap_space_statistics_buffer();

for (size_t i = 0; i < number_of_heap_spaces; i++) {
for (size_t i = 0; i < isolate->NumberOfHeapSpaces(); i++) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: cache the value in a local so it's only one function call instead of n function calls.

@BridgeAR
Copy link
Member

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 28, 2018
@addaleax
Copy link
Member Author

addaleax commented Jun 1, 2018

Landed in e1df688

@addaleax addaleax closed this Jun 1, 2018
@addaleax addaleax deleted the number-of-heap-spaces branch June 1, 2018 09:23
addaleax added a commit that referenced this pull request Jun 1, 2018
While `NumberOfHeapSpaces()` currently returns a constant value,
that is not strictly guaranteed by the V8 API as far as I can tell.
Therefore, caching it globally does not seem appropriate.

(The motivation here is that this squelches warnings which are
produced by concurrency debugging tooling due to the apparent
race conditions when accessing the global variable.)

PR-URL: #20971
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 6, 2018
While `NumberOfHeapSpaces()` currently returns a constant value,
that is not strictly guaranteed by the V8 API as far as I can tell.
Therefore, caching it globally does not seem appropriate.

(The motivation here is that this squelches warnings which are
produced by concurrency debugging tooling due to the apparent
race conditions when accessing the global variable.)

PR-URL: #20971
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jun 6, 2018
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.

8 participants