Skip to content

Conversation

@bnoordhuis
Copy link
Member

@bnoordhuisbnoordhuis commented Apr 17, 2017

HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock()
used to self-recurse before this commit, causing stack overflows on
systems with small stack sizes. Make it non-recursive by storing
intermediate results in a heap-allocated list.

The first commit is the obvious way to implement it, the second commit optimizes a bit.

Switching to heap allocations might in theory have performance implications but, as a data point, it doesn't seem to affect the running time of the node.js test suite.

V8 CI (1st commit): https://ci.nodejs.org/job/node-test-commit-v8-linux/651/ (green)
V8 CI (2nd commit): https://ci.nodejs.org/job/node-test-commit-v8-linux/652/ (green)
V8 CI (3rd commit): https://ci.nodejs.org/job/node-test-commit-v8-linux/653/
Node CI (2nd commit): https://ci.nodejs.org/job/node-test-pull-request/7439/
Node CI (3rd commit): https://ci.nodejs.org/job/node-test-pull-request/7466/

See #11991.

@nodejs-github-botnodejs-github-bot added the v8 engine Issues and PRs related to the V8 dependency. label Apr 17, 2017
@bnoordhuisbnoordhuis changed the title Fix11991v8: fix stack overflow in recursive method Apr 17, 2017
@hashseed
Copy link
Member

I don't expect any performance impact because this part of Crankshaft should run on the background thread anyways.

Copy link
Member

@hashseedhashseed left a comment

Choose a reason for hiding this comment

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

You probably can use the list as a stack (instead of queue) and just pop the last element at the end of the loop? That would lessen the peak memory use.

@bnoordhuis
Copy link
MemberAuthor

Made the suggested change. I wasn't sure if walking them in a different order was sound but it computes the union so I suppose it must be.

V8 CI: https://ci.nodejs.org/job/node-test-commit-v8-linux/653/
Node CI: https://ci.nodejs.org/job/node-test-pull-request/7466/

@hashseed
Copy link
Member

LGTM.

FWIW 2nd commit didn't traverse the same order as the recursion did either (BFS vs DFS).

Copy link
Member

@jasnelljasnell 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 is this a backport of a change in V8? or should this land upstream first?

@hashseed
Copy link
Member

V8 is not likely to ship a version with this patch anymore, and Crankshaft is being deprecated, so I'm not sure how much value upstreaming has. I would give lgtm if @bnoordhuis provides a CL for upstream though.

@bnoordhuis
Copy link
MemberAuthor

I'm fine with floating it as a patch. Upstreaming it would be make-work for the both of us.

HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: nodejs#11991 PR-URL: nodejs#12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
@bnoordhuisbnoordhuis deleted the fix11991 branch April 21, 2017 08:50
@bnoordhuisbnoordhuis merged commit 30989d3 into nodejs:masterApr 21, 2017
targos pushed a commit that referenced this pull request Apr 24, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
evanlucas pushed a commit that referenced this pull request Apr 25, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
targos pushed a commit that referenced this pull request Apr 26, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
targos pushed a commit that referenced this pull request Apr 27, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
targos pushed a commit that referenced this pull request Apr 28, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
targos pushed a commit that referenced this pull request May 1, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
@evanlucasevanlucas mentioned this pull request May 1, 2017
evanlucas pushed a commit that referenced this pull request May 1, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
evanlucas pushed a commit that referenced this pull request May 2, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
addaleax pushed a commit that referenced this pull request Jul 11, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
addaleax pushed a commit that referenced this pull request Jul 18, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: nodejs/node#11991 PR-URL: nodejs/node#12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
targos pushed a commit to targos/node that referenced this pull request Jul 21, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: nodejs#11991 PR-URL: nodejs#12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
addaleax pushed a commit that referenced this pull request Jul 24, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
@addaleaxaddaleax mentioned this pull request Jul 24, 2017
MylesBorins pushed a commit to MylesBorins/node that referenced this pull request Aug 1, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: nodejs#11991 PR-URL: nodejs#12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
MylesBorins pushed a commit to MylesBorins/node that referenced this pull request Aug 1, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: nodejs#11991 Refs: nodejs#12460 PR-URL: nodejs#14004 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Aug 1, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 Refs: #12460 PR-URL: #14004 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
addaleax pushed a commit that referenced this pull request Aug 2, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 Refs: #12460 Backport-PR-URL: #14574 Backport-Reviewed-By: Anna Henningsen <[email protected]> Backport-Reviewed-By: Refael Ackermann <[email protected]> PR-URL: #14004 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Sep 20, 2017
MylesBorins pushed a commit that referenced this pull request Oct 25, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: #11991 Backport-PR-URL: #13080 PR-URL: #12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Oct 25, 2017
gibfahn pushed a commit to ibmruntimes/node that referenced this pull request Nov 24, 2017
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock() used to self-recurse before this commit, causing stack overflows on systems with small stack sizes. Make it non-recursive by storing intermediate results in a heap-allocated list. Fixes: nodejs/node#11991 Backport-PR-URL: nodejs/node#13080 PR-URL: nodejs/node#12460 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v8 engineIssues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@bnoordhuis@hashseed@gibfahn@jasnell@addaleax@nodejs-github-bot