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
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a28ef1b
doc: add new useful V8 option
JialuZhang-intel Apr 2, 2022
b960c66
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
3ae0f49
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
6813f99
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
7b1739c
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
dddff28
Apply suggestions from code review
JialuZhang-intel Apr 3, 2022
a05b327
Update doc/api/cli.md
JialuZhang-intel Apr 8, 2022
eb1eec7
Remove recommended value for max_semi_space_size
JialuZhang-intel May 5, 2022
d1defe3
Merge branch 'nodejs:master' into document_max_semi_space_size
JialuZhang-intel May 5, 2022
91a151a
doc: update format for cli.md
JialuZhang-intel May 5, 2022
0dfd5e5
doc: add new useful V8 option
JialuZhang-intel May 5, 2022
f91e536
Apply suggestions from code review
JialuZhang-intel May 5, 2022
1bb2ad7
doc: add new useful V8 option
JialuZhang-intel May 5, 2022
4fc45b6
doc: add new useful V8 option
JialuZhang-intel May 5, 2022
e1c0732
Apply suggestions from code review
JialuZhang-intel May 6, 2022
4ef953f
Update doc/api/cli.md
JialuZhang-intel Jun 12, 2022
5574419
Update doc/api/cli.md
JialuZhang-intel Jun 13, 2022
1deaca4
Merge branch 'nodejs:master' into document_max_semi_space_size
JialuZhang-intel Jun 13, 2022
db7d07d
doc: add new useful V8 option
JialuZhang-intel Jun 13, 2022
baa9c9b
Merge branch 'document_max_semi_space_size' of https://github.com/Jia…
JialuZhang-intel Jun 13, 2022
5411215
doc: add new useful V8 option
JialuZhang-intel Jun 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,21 @@ On a machine with 2 GB of memory, consider setting this to
$ node --max-old-space-size=1536 index.js
```

### `--max_semi_space_size=SIZE` (in megabytes)

Sets the maximum
[semi-space](https://www.memorymanagement.org/glossary/s.html#semi.space)
size for V8's [scavenge](https://v8.dev/blog/orinoco-parallel-scavenger)
garbage collector in MiB.
Increasing the max size of a semi-space may bring
throughput improvement for Node.js and the cost is more
memory consumption (see [#42511](https://github.com/nodejs/node/issues/42511)).

_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.

memory._

[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
[CommonJS]: modules.md
[ECMAScript module loader]: esm.md#loaders
Expand Down