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

doc: add new useful V8 option #42575

Merged
merged 21 commits into from
Jun 17, 2022

Conversation

JialuZhang-intel
Copy link
Contributor

Add the '--max_semi_space_size' flag into useful V8 option.

Fixes: #42511

Add the '--max_semi_space_size' flag into useful V8 option.

Fixes: nodejs#42511
@nodejs-github-bot nodejs-github-bot added cli Issues and PRs related to the Node.js command line interface. doc Issues and PRs related to the documentations. labels Apr 2, 2022
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
JialuZhang-intel and others added 3 commits April 2, 2022 20:08
Co-authored-by: Mohammed Keyvanzadeh <[email protected]>
Co-authored-by: Mohammed Keyvanzadeh <[email protected]>
Co-authored-by: Mohammed Keyvanzadeh <[email protected]>
doc/api/cli.md Outdated Show resolved Hide resolved
Co-authored-by: Mohammed Keyvanzadeh <[email protected]>
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated
Comment on lines 1992 to 1994
The actual throughput improvement and memory consumption
are relevant to your application
([reference](https://github.com/nodejs/node/issues/42511)).
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand this sentence, do you mean it's relevant to any Node.js application, and if so, how do you know?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tuned the max_semi_space_size value and tested it on two workloads, this is the results:
img
From the figure we can see that the trend of throughput improve are similar on both workloads, but the absolute value are different. I just want the user to test and choose the optimal configuration for their own application.

doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
Co-authored-by: Antoine du Hamel <[email protected]>
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated

_The default value is
16MiB for 64-bit systems and 8MiB for 32-bit systems.
The recommended value is 64MiB or 128MiB if your system has enough
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if there a rational we can include for choosing these as the recommendation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, there isn't too much optional value for the 'max_semi_space_size', because V8 did the round up operation to make sure the 'max_semi_space_size' is the power of 2. So, only if we set the value of 'max_semi_space_size' to 16MiB, 32MiB, 64MiB, 128MiB, 256MiB and so on, the behavior is what we expected. I tuned these value on WebTooling and Ghost.js workloads, the result shows that 128MiB is the optimal configuration for both of these workloads.
result
I don't know if it is appropriate to put this image into the document. So I just put the link of issue #42511 in the document.

Copy link
Member

Choose a reason for hiding this comment

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

I'd refrain from recommending specific values, just that higher values can give better throughput but the reader should benchmark that.

It should also mention that the size is effectively tripled because there is more than one semi space. Observe:

$ for MB in 16 32 64 128; do
    node --max_semi_space_size=$MB --max_old_space_size=16 -p \
    'const MB = 1<<20; (v8.getHeapStatistics().heap_size_limit - 16*MB) / MB';
  done
48
96
192
384

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bnoordhuis Thanks for your suggestion! I have updated the patch to guide users to choose the max_semi_space_size for themselves.

Co-authored-by: Michael Dawson <[email protected]>
Copy link

@lamweili lamweili left a comment

Choose a reason for hiding this comment

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

Hi @JialuZhang-intel, my humble 2 cents.
In addition, perhaps should use reference-style links instead of inline links.

doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Show resolved Hide resolved
More detailed explanation about memory consumption and semi-space size.
doc/api/cli.md Outdated Show resolved Hide resolved
Copy link

@lamweili lamweili left a comment

Choose a reason for hiding this comment

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

For better clarity (from 0dfd5e5), maybe? 😅

doc/api/cli.md Outdated Show resolved Hide resolved
doc/api/cli.md Outdated Show resolved Hide resolved
Copy link

@lamweili lamweili left a comment

Choose a reason for hiding this comment

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

For consistency with cli.md, should use reference-style links instead of inline links.

JialuZhang-intel and others added 2 commits May 5, 2022 17:34
Co-authored-by: Lam Wei Li <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
use reference-style links instead of inline links.
@JialuZhang-intel
Copy link
Contributor Author

For consistency with cli.md, should use reference-style links instead of inline links.

@peteriman Thanks for your advice! I changed the links styles in this patch.
For the link of #42511, I think it's special for this option, so I kept it as inline.

@JialuZhang-intel
Copy link
Contributor Author

JialuZhang-intel commented Jun 9, 2022

It's been a long time and a lot of updates since this PR created. Thanks for the suggestions from all the reviewers @mhdawson @aduh95 @bnoordhuis @VoltrexMaster @peteriman @joyeecheung. Is there anything else need to fix about this PR?

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, @JialuZhang-intel. Looks great!

doc/api/cli.md Outdated Show resolved Hide resolved
Co-authored-by: James M Snell <[email protected]>
doc/api/cli.md Outdated Show resolved Hide resolved
@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 13, 2022
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@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 17, 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 17, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/42575
✔  Done loading data for nodejs/node/pull/42575
----------------------------------- PR info ------------------------------------
Title      doc: add new useful V8 option (#42575)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     JialuZhang-intel:document_max_semi_space_size -> nodejs:main
Labels     doc, cli, author ready, commit-queue-squash
Commits    21
 - doc: add new useful V8 option
 - Update doc/api/cli.md
 - Update doc/api/cli.md
 - Update doc/api/cli.md
 - Update doc/api/cli.md
 - Apply suggestions from code review
 - Update doc/api/cli.md
 - Remove recommended value for max_semi_space_size
 - Merge branch 'nodejs:master' into document_max_semi_space_size
 - doc: update format for cli.md
 - doc: add new useful V8 option
 - Apply suggestions from code review
 - doc: add new useful V8 option
 - doc: add new useful V8 option
 - Apply suggestions from code review
 - Update doc/api/cli.md
 - Update doc/api/cli.md
 - Merge branch 'nodejs:master' into document_max_semi_space_size
 - doc: add new useful V8 option
 - Merge branch 'document_max_semi_space_size' of https://github.com/Jia…
 - doc: add new useful V8 option
Committers 2
 - JialuZhang-intel 
 - GitHub 
PR-URL: https://github.com/nodejs/node/pull/42575
Fixes: https://github.com/nodejs/node/issues/42511
Reviewed-By: Ben Noordhuis 
Reviewed-By: James M Snell 
Reviewed-By: Michael Dawson 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/42575
Fixes: https://github.com/nodejs/node/issues/42511
Reviewed-By: Ben Noordhuis 
Reviewed-By: James M Snell 
Reviewed-By: Michael Dawson 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sat, 02 Apr 2022 10:49:25 GMT
   ✔  Approvals: 3
   ✔  - Ben Noordhuis (@bnoordhuis): https://github.com/nodejs/node/pull/42575#pullrequestreview-1000860391
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/42575#pullrequestreview-1003513324
   ✔  - Michael Dawson (@mhdawson) (TSC): https://github.com/nodejs/node/pull/42575#pullrequestreview-1004903706
   ✔  Last GitHub CI successful
   ℹ  Green GitHub CI is sufficient
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
   7f195189f0..7fd4cf4673  main       -> origin/main
✔  origin/main is now up-to-date
main is out of sync with origin/main. Mismatched commits:
 - 7fd4cf4673 loader: make `require.resolve` throw for unknown builtin modules
--------------------------------------------------------------------------------
HEAD is now at 7fd4cf4673 loader: make `require.resolve` throw for unknown builtin modules
   ✔  Reset to origin/main
- Downloading patch for 42575
From https://github.com/nodejs/node
 * branch                  refs/pull/42575/merge -> FETCH_HEAD
✔  Fetched commits as b6c6cc70009d..5411215a072a
--------------------------------------------------------------------------------
Auto-merging doc/api/cli.md
[main 1fea61e77a] doc: add new useful V8 option
 Author: JialuZhang-intel 
 Date: Sat Apr 2 18:35:30 2022 +0800
 1 file changed, 16 insertions(+)
Auto-merging doc/api/cli.md
[main 1a6964161e] Update doc/api/cli.md
 Author: JialuZhang-intel 
 Date: Sat Apr 2 20:08:45 2022 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)
Auto-merging doc/api/cli.md
[main 73a0b57a4b] Update doc/api/cli.md
 Author: JialuZhang-intel 
 Date: Sat Apr 2 20:09:00 2022 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)
Auto-merging doc/api/cli.md
[main adc451fecd] Update doc/api/cli.md
 Author: JialuZhang-intel 
 Date: Sat Apr 2 20:09:15 2022 +0800
 1 file changed, 2 insertions(+), 1 deletion(-)
Auto-merging doc/api/cli.md
[main c6690802c2] Update doc/api/cli.md
 Author: JialuZhang-intel 
 Date: Sat Apr 2 20:17:06 2022 +0800
 1 file changed, 3 insertions(+), 2 deletions(-)
Auto-merging doc/api/cli.md
[main 2cd6076c8c] Apply suggestions from code review
 Author: JialuZhang-intel 
 Date: Sun Apr 3 13:06:22 2022 +0800
 1 file changed, 8 insertions(+), 11 deletions(-)
Auto-merging doc/api/cli.md
[main fba60b1b8e] Update doc/api/cli.md
 Author: JialuZhang-intel 
 Date: Fri Apr 8 10:15:09 2022 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)
Auto-merging doc/api/cli.md
error: commit d1defe3c16419451925e4e4f672a279cbcf1185d is a merge but no -m option was given.
fatal: cherry-pick failed
[main 7de3968c3a] Remove recommended value for max_semi_space_size
 Author: JialuZhang-intel 
 Date: Thu May 5 10:58:55 2022 +0800
 1 file changed, 15 insertions(+), 6 deletions(-)
   ✖  Failed to apply patches
https://github.com/nodejs/node/actions/runs/2514254971

@aduh95 aduh95 merged commit f7770ed into nodejs:main Jun 17, 2022
@aduh95
Copy link
Contributor

aduh95 commented Jun 17, 2022

Landed in f7770ed

Copy link

@lamweili lamweili left a comment

Choose a reason for hiding this comment

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

Thanks!

targos pushed a commit that referenced this pull request Jul 12, 2022
Add the `--max_semi_space_size` flag into useful V8 option.

Fixes: #42511

PR-URL: #42575
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2022
Add the `--max_semi_space_size` flag into useful V8 option.

Fixes: #42511

PR-URL: #42575
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
Add the `--max_semi_space_size` flag into useful V8 option.

Fixes: nodejs/node#42511

PR-URL: nodejs/node#42575
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@joebowbeer
Copy link
Contributor

joebowbeer commented Nov 5, 2024

@JialuZhang-intel the default max-semi-space-size is now (v20+) dependent on memory limit and is (more) likely to be sub-optimal for memory limits of 2GiB or less.

See #55487

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. cli Issues and PRs related to the Node.js command line interface. 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. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase default 'max_semi_space_size' value to reduce GC overhead in V8
9 participants