GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: call gc() explicitly to avoid OOM by refack · Pull Request #22301 · nodejs/node

Conversation

@refack

@refack refack commented Aug 13, 2018

Copy link
Copy Markdown
Contributor

Refs: nodejs/reliability#12
Refs: #16354

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung and mike442144 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@refack refack added flaky-test Issues and PRs involving tests that fail intermittently in CI. fast-track PRs proposed for a shorter-than-standard waiting period before landing. labels Aug 13, 2018
@nodejs-github-bot

nodejs-github-bot commented Aug 13, 2018

Copy link
Copy Markdown
Collaborator

@refack build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/550/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack
refack requested review from Trott and joyeecheung August 13, 2018 20:21
@nodejs-github-bot nodejs-github-bot added addons Issues and PRs related to native addons. test Issues and PRs related to Node.js core tests and test infrastructure. labels Aug 13, 2018
@refack

refack commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Stress CI: https://ci.nodejs.org/job/node-stress-single-test/1988/nodes=freebsd11-x64/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott approved these changes Aug 13, 2018
View reviewed changes
joyeecheung
joyeecheung reviewed Aug 13, 2018
View reviewed changes
Comment thread test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js Outdated

@joyeecheung joyeecheung Aug 13, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe add a FIXME here since it's not supposed to crash? This is just a quick fix

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@refack refack Aug 13, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ack.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@refack
refack force-pushed the less-OOM-for-freebsd-by-max-string branch from ca53596 to d970a8a Compare August 13, 2018 20:29
@Trott

Trott commented Aug 13, 2018

Copy link
Copy Markdown
Member

/ping @nodejs/v8 on "shouldn't setting to undefined cause garbage collection in this situation?" and maybe also the "why does this crash?" As @joyeecheung points out, this shouldn't crash, so something weird is up. Not sure if it's specific to FreeBSD or specific to something we've configured that happens to be on our FreeBSD machines in CI. (Or something else?) See nodejs/reliability#12 for a small bit of context.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR
BridgeAR approved these changes Aug 13, 2018
View reviewed changes
joyeecheung
joyeecheung approved these changes Aug 13, 2018
View reviewed changes
addaleax
addaleax reviewed Aug 13, 2018
View reviewed changes
Comment thread test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js Outdated

@addaleax addaleax Aug 13, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Semicolons? ;)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@refack refack Aug 13, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

oh my 😳

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung

joyeecheung commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I've started another stress test (1989 pending the current one 1988) with master for comparison

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack

refack commented Aug 13, 2018

Copy link
Copy Markdown
Contributor Author

/CC @nodejs/testing some low hanging time optimization fruit:

18:21:53 + python tools/test.py -p tap --mode=release 'addons/stringbytes-external-exceed-max/test-stringbytes*'
18:21:54 TAP version 13
18:21:54 1..8
18:22:08 ok 1 addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max
18:22:08   ---
18:22:08   duration_ms: 13.920
18:22:08   ...
18:23:09 ok 2 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max
18:23:09   ---
18:23:09   duration_ms: 60.658
18:23:09   ...
18:23:19 ok 3 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii
18:23:19   ---
18:23:19   duration_ms: 10.175
18:23:19   ...
18:23:44 ok 4 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64
18:23:44   ---
18:23:44   duration_ms: 24.288
18:23:44   ...
18:24:17 ok 5 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary
18:24:17   ---
18:24:17   duration_ms: 33.149
18:24:17   ...
18:25:06 ok 6 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex
18:25:06   ---
18:25:06   duration_ms: 49.453
18:25:06   ...
18:25:07 ok 7 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8
18:25:07   ---
18:25:07   duration_ms: 0.399
18:25:07   ...
18:25:21 ok 8 addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2
18:25:21   ---
18:25:21   duration_ms: 13.908
18:25:21   ...
18:25:21 + OK=21
18:25:21 + echo '21   OK: 21   NOT OK: 0   TOTAL: 100'
18:25:21 21   OK: 21   NOT OK: 0   TOTAL: 100
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devsnek

devsnek commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@Trott

shouldn't setting to undefined cause garbage collection in this situation?

v8 has a fairly lazy gc by default. setting a variable to undefined clears the reference to the value but the value might not be deleted until the next gc, and even then it might be removed from v8's heap but v8's heap might not shrink. there is a new method in v8 called EnableMemorySavingsMode which might help with this.

why does this crash?

v8 will allocate the second and third strings without deleting the previous ones. as far as i know v8 doesn't track how much memory the system actually has. because of this it has a method called LowMemoryNotification and another one called MemoryPressureNotification which enable the embedder to tell v8 that there isn't any more memory for it to use.


someone actually brought up on irc yesterday this topic about having more control over how node (and by extension v8) is using memory. i'm wondering if maybe we could work on exposing some options around that to applications.

Trott and gireeshpunathil reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

devsnek
devsnek approved these changes Aug 13, 2018
View reviewed changes
@joyeecheung

joyeecheung commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@devsnek ExternString::NewFromCopy is supposed to return an empty maybe when there is not enough memory so that an error can be thrown later, v8 failing to GC the previous strings are not supposed to cause crashes..

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Aug 13, 2018

Copy link
Copy Markdown
Member

By the way I can't seem to reproduce this in a new FreeBSD box, maybe it has something to do with the resource usage on our CI machines and you'd need to hit a certain threshold to get the crash. @refack have you managed to get a core dump?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devsnek

devsnek commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@joyeecheung i meant that if v8 tries to allocate and hits OOM it will abort. there might also be a callback to catch that. i don't know what it does if it fails to deallocate.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@devsnek The majority of the allocation is not supposed to happen in the V8 heap, since it's an external string...also nodejs/reliability#12 (comment) didn't give us the usual OOM message from V8, it's killed by the system so it's probably caused by some system call hitting the resource limit (whereas if the OOM happens in V8's heap V8 will print that OOM message before aborting). The actual V8 heap is only a few megabytes in https://www.irccloud.com/pastebin/FI3zgCwR/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack

refack commented Aug 14, 2018

Copy link
Copy Markdown
Contributor Author

CI: https://ci.nodejs.org/job/node-test-pull-request/16431/
If it's green, I'm gonna land (since this unbreaks CI)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack

refack commented Aug 14, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I've started another stress test (1989 pending the current one 1988) with master for comparison

Stress test against master crashed after 5 repeats:

echo '5   OK: 1   NOT OK: 4   TOTAL: 100'

But I think that is a significant enough result.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack refack added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Aug 14, 2018
@Trott

Trott commented Aug 14, 2018

Copy link
Copy Markdown
Member

👍 here to fast-track.

Trott and devsnek reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 14, 2018

Copy link
Copy Markdown
Member

Resume build: https://ci.nodejs.org/job/node-test-pull-request/16433/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 14, 2018

Copy link
Copy Markdown
Member

Although it looks like https://ci.nodejs.org/job/node-test-pull-request/16432/ is a Resume Build that's already green so mine is unnecessary. This can land once we get a second fast-track approval. Someone? Anyone?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gireeshpunathil

gireeshpunathil commented Aug 14, 2018

Copy link
Copy Markdown
Member

setting a variable to undefined clears the reference to the value but the value might not be deleted until the next gc, and even then it might be removed from v8's heap but v8's heap might not shrink.

@devsnek - does this mean that (large and complex) applications should explicitly invoke gc() to avoid garbage pileup? that is in direct contradiction with the automatic garbage collection promise. I would assume gc() to abort only after it has cleared up even the last byte of garbage and still cannot allocate the current request.

To me, this looks like a v8 bug.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hashseed

hashseed commented Aug 14, 2018

Copy link
Copy Markdown
Member

@ulan @hannespayer I'm also a bit surprised that you need to explicitly call GC to avoid OOM.

gireeshpunathil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devsnek

devsnek commented Aug 14, 2018

Copy link
Copy Markdown
Member

@gireeshpunathil

does this mean that (large and complex) applications should explicitly invoke gc() to avoid garbage pileup? ... I would assume gc() to abort only after it has cleared up even the last byte of garbage and still cannot allocate the current request.

that is how v8 behaves (https://github.com/v8/v8/blob/3f0346cdedb230a89dc433ade7e46ac7129ba5e4/src/heap/heap.cc#L4608-L4648)

there was some missing context here... this test allocates external strings, not v8 heap strings, so from what i understand the failure is actually a bug with node, not v8. this fact, of course, plugs into hashseed's comment.

gireeshpunathil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack
test: call gc() explicitly to avoid OOM
4ce744a
PR-URL: nodejs#22301
Refs: nodejs/reliability#12
Refs: nodejs#16354
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@refack
refack force-pushed the less-OOM-for-freebsd-by-max-string branch from 4757c91 to 4ce744a Compare August 14, 2018 06:29
@refack

refack commented Aug 14, 2018

Copy link
Copy Markdown
Contributor Author

Landed in 4ce744a

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack
refack merged commit 4ce744a into nodejs:master Aug 14, 2018
@refack
refack deleted the less-OOM-for-freebsd-by-max-string branch August 14, 2018 06:30
@joyeecheung

joyeecheung commented Aug 14, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Looks like the test is still crashing https://ci.nodejs.org/job/node-test-commit-freebsd/19642/nodes=freebsd11-x64/console

EDIT: that CI was not rebased against this commit

refack reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung mentioned this pull request Aug 14, 2018
Investigate flaky addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary on FreeBSD 11 #22317
Closed
@mlippautz

mlippautz commented Aug 14, 2018

Copy link
Copy Markdown

tl;dr: This should be fixed by V8 soon.

V8 relies on embedders calling AdjustAmountOfExternalAllocatedMemory for memory that externally allocated. This is error prone and the API does not follow any growing strategy for allocated memory, making it likely that it is not doing not enough or too many GCs.

We know that this is an issue and there's ongoing work that is about to be landed on master handling types where V8 has more knowledge (externalized strings & array buffers).

Specifically, the external string issue should be fixed as soon as that CL lands.

gireeshpunathil and BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rvagg pushed a commit that referenced this pull request Aug 15, 2018
@refack @rvagg
test: call gc() explicitly to avoid OOM
9feee1f
PR-URL: #22301
Refs: nodejs/reliability#12
Refs: #16354
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@rvagg rvagg mentioned this pull request Aug 15, 2018
Release proposal: v10.9.0 #22295
Merged
@joyeecheung joyeecheung mentioned this pull request Aug 15, 2018
CI failures: 20180815 nodejs/reliability#13
Closed
This was referenced Aug 16, 2018
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#230
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#215
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#231
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#216
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#232
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#217
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#233
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#218
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#234
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#219
Closed
@joyeecheung joyeecheung mentioned this pull request Aug 17, 2018
CI Failures: 20180817 nodejs/reliability#14
Closed
@rubys rubys mentioned this pull request Aug 21, 2018
util: Fix number format for pad #21906
Closed
2 tasks done
@MylesBorins MylesBorins added the land-on-v8.x label Sep 26, 2018
MylesBorins pushed a commit that referenced this pull request Oct 2, 2018
@refack @MylesBorins
test: call gc() explicitly to avoid OOM
d58867a
PR-URL: #22301
Refs: nodejs/reliability#12
Refs: #16354
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Oct 30, 2018
v8.13.0 proposal #23974
Merged
@beevelop beevelop mentioned this pull request Nov 20, 2018
2018-11-20 Version 8.13.0 'Carbon' (LTS) @MylesBorins prepared by @BethGriggs beevelop/docker-android-nodejs#250
Closed
firass111 pushed a commit to firass111/Project_node1 that referenced this pull request Apr 16, 2025
@refack @rvagg
test: call gc() explicitly to avoid OOM
1d15f33
PR-URL: nodejs/node#22301
Refs: nodejs/reliability#12
Refs: nodejs/node#16354
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax left review comments
@Trott Trott Trott approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
+1 more reviewer
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

addons Issues and PRs related to native addons. author ready PRs with CI started, the required approvals, and no outstanding review comments. fast-track PRs proposed for a shorter-than-standard waiting period before landing. flaky-test Issues and PRs involving tests that fail intermittently in CI. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@refack @nodejs-github-bot @Trott @joyeecheung @devsnek @gireeshpunathil @hashseed @mlippautz @addaleax @BridgeAR @MylesBorins
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.