Bug 144609 - GC has trouble with pathologically large array allocations
Summary: GC has trouble with pathologically large array allocations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
: 144677 (view as bug list)
Depends on: 144691
Blocks: 144749 144750
  Show dependency treegraph
 
Reported: 2015-05-04 17:09 PDT by Filip Pizlo
Modified: 2015-05-07 19:14 PDT (History)
13 users (show)

See Also:


Attachments
the patch (7.53 KB, patch)
2015-05-05 18:53 PDT, Filip Pizlo
mark.lam: review+
Details | Formatted Diff | Diff
the patch (16.51 KB, patch)
2015-05-07 10:46 PDT, Filip Pizlo
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2015-05-04 17:09:49 PDT
Patch forthcoming.
Comment 1 Filip Pizlo 2015-05-04 17:10:13 PDT
Consider the following test, if you tweak the size so that we actually allocate the memory.  It causes linear heap growth.


function foo(x) {
    return new Array(x);
}

noInline(foo);

function test(size) {
    var result = foo(size);
    if (result.length != size)
        throw "Error: bad result: " + result;
    var sawThings = false;
    for (var s in result)
        sawThings = true;
    if (sawThings)
        throw "Error: array is in bad state: " + result;
    result[0] = "42.5";
    if (result[0] != "42.5")
        throw "Error: array is in wierd state: " + result;
}

for (var i = 0; i < 100000; ++i) {
    test(1000000);
}
Comment 2 Filip Pizlo 2015-05-05 18:53:09 PDT
Created attachment 252432 [details]
the patch
Comment 3 Mark Lam 2015-05-05 19:53:43 PDT
Comment on attachment 252432 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=252432&action=review

r=me

> Source/JavaScriptCore/tests/stress/new-largeish-contiguous-array-with-size.js:23
> +        throw "Error: array is in wierd state: " + result;

I believe the correct spelling here is "weird".  Can you fix this and the one in new-array-storage-array-with-size.js as well?

> Source/JavaScriptCore/tests/stress/new-largeish-contiguous-array-with-size.js:28
> +for (var i = 0; i < 40000; ++i) {
> +    test(50000);
> +}

Please add a comment above this to indicate that if GC doesn't clean up adequately, then the heap can grow unreasonably large (in the order of 40000 * 50000 * 8), and would end up much larger than the 100M tested below.  While this purpose can be inferred, it is not clear.  I think a comment will make it explicit and help the reader see right away what the test is trying to check for.
Comment 4 Filip Pizlo 2015-05-05 20:41:14 PDT
Landed in http://trac.webkit.org/changeset/183847
Comment 5 Csaba Osztrogonác 2015-05-05 22:59:22 PDT
(In reply to comment #4)
> Landed in http://trac.webkit.org/changeset/183847

It caused assertions on the debug bots. Could you check it?
Comment 6 Filip Pizlo 2015-05-05 23:01:14 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > Landed in http://trac.webkit.org/changeset/183847
> 
> It caused assertions on the debug bots. Could you check it?

See: https://bugs.webkit.org/show_bug.cgi?id=144667

Should be fixed in http://trac.webkit.org/changeset/183851
Comment 7 Csaba Osztrogonác 2015-05-06 00:45:35 PDT
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > Landed in http://trac.webkit.org/changeset/183847
> > 
> > It caused assertions on the debug bots. Could you check it?
> 
> See: https://bugs.webkit.org/show_bug.cgi?id=144667
> 
> Should be fixed in http://trac.webkit.org/changeset/183851

Yes, it fixed the assertions, thanks.

But unfortunately the new test fails on 32 bit ARM Linux bots:

stress/new-largeish-contiguous-array-with-size.js.default: Exception: Error: heap too big before forced GC: 129308808
stress/new-largeish-contiguous-array-with-size.js.default: ERROR: Unexpected exit code: 3
FAIL: stress/new-largeish-contiguous-array-with-size.js.default

stress/new-largeish-contiguous-array-with-size.js.default: Exception: Error: heap too big before forced GC: 130977916
stress/new-largeish-contiguous-array-with-size.js.default: ERROR: Unexpected exit code: 3
FAIL: stress/new-largeish-contiguous-array-with-size.js.default
Comment 8 Csaba Osztrogonác 2015-05-06 01:43:38 PDT
And there are still 25-30 layout test assertions.
Comment 9 Alexey Proskuryakov 2015-05-06 09:47:23 PDT
E.g. this one: <https://webkit-test-results.appspot.com/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=fast%2Fworkers%2Fworker-gc2.html>.

Rolling out (Csaba, why didn't you?)
Comment 10 WebKit Commit Bot 2015-05-06 09:48:23 PDT
Re-opened since this is blocked by bug 144691
Comment 11 Alexey Proskuryakov 2015-05-06 09:52:56 PDT
There are also assorted JSC test failures. Hard to tell if they are all caused by this patch, there was a lot of churn last night.

https://build.webkit.org/builders/Apple%20Yosemite%20Debug%20JSC%20%28Tests%29/builds/1241/steps/jscore-test/logs/stdio

https://build.webkit.org/builders/Apple%20Win%207%20Debug%20%28Tests%29/builds/66067/steps/jscore-test/logs/stdio
Comment 12 Filip Pizlo 2015-05-06 22:09:18 PDT
Man, this bug is turning out to be brutal.  It appears that an old gen block is revived into new space and then deleted.  But because we haven't done a full collection yet, our running total of blocks includes that block.  Hence the assertion failure.

All of this feels very wrong.
Comment 13 Filip Pizlo 2015-05-06 22:19:21 PDT
Aha!  We are resizing blocks.  This means that our count of the size of old space is wrong, because we will double-count: we will count both the block we deleted and the block we created.
Comment 14 Csaba Osztrogonác 2015-05-07 04:32:30 PDT
(In reply to comment #9)
> Rolling out (Csaba, why didn't you?)

I was the bad guy for too long and I was fed up with getting angry comments,
so I promised not to roll out others patches even if it broke the whole world.

Patch owners are responsible for their patches, they should respect the EWS
bubbles, watch the bots after landing. I won't argue with anybody and won't
ask anybody to respect the policies.
Comment 15 Filip Pizlo 2015-05-07 10:46:58 PDT
Created attachment 252599 [details]
the patch
Comment 16 Geoffrey Garen 2015-05-07 10:55:44 PDT
Comment on attachment 252599 [details]
the patch

I'm OK with this solution. But I also think we should just remove that immediate deallocation feature. That's just not how garbage collection works, and making it work that way some small percentage of the time doesn't strike me as valuable.
Comment 17 Filip Pizlo 2015-05-07 11:10:32 PDT
*** Bug 144677 has been marked as a duplicate of this bug. ***
Comment 18 Filip Pizlo 2015-05-07 11:14:55 PDT
(In reply to comment #16)
> Comment on attachment 252599 [details]
> the patch
> 
> I'm OK with this solution. But I also think we should just remove that
> immediate deallocation feature. That's just not how garbage collection
> works, and making it work that way some small percentage of the time doesn't
> strike me as valuable.

I agree. Filed: https://bugs.webkit.org/show_bug.cgi?id=144750
Comment 19 Filip Pizlo 2015-05-07 19:14:36 PDT
Landed in http://trac.webkit.org/changeset/183974