Updates:
        Status: Accepted
        Cc: [email protected] [email protected]

Comment #1 on issue 2452 by [email protected]: Array.shift extremely slow when array has >= 128991 elements
http://code.google.com/p/v8/issues/detail?id=2452

I modified your test to run it in d8:

function time(fn) {
    var start = new Date();
    fn();
    var end = new Date();
    print(end - start);
}

[1e3, 1e4, 1e5, 122000, 132000].forEach(function (num) {
    var a = new Array(num).join(',').split(',');
    print(num);
    time(function shiftFn() {
        while (a.length) a.shift();
    });
});

For me, the break didn't happen at 128991, but somewhat higher, but the problem remains. A profile without the problematic size looks like this:

      2032   9.7% v8::internal::Builtin_ArrayShift
       633   3.0% v8::internal::LeftTrimFixedArray
       547   2.6% GLIBC_2.0   _IO_vfprintf
       522   2.5% v8::internal::Runtime_StringSplit
       477   2.3% v8::internal::Factory::NewProperSubString
             [...]

which is alright. If I add that 132000 to the list (and abort the run after only a few seconds), the profile looks wildly different:

    286270  48.9% v8::internal::StoreBuffer::Compact()
151530 25.9% _ZN2v88internalL12MoveElementsEPNS0_4HeapEPNS0_18AssertNoAllocationEPNS0_10FixedArrayEiS6_ii.isra.78.part.79 108651 18.6% _ZN2v88internal11StoreBuffer6FilterEi.constprop.48 [/usr/local/google/home/yangguo/v8/out/ia32.release/d8]
      2056   0.4% v8::internal::Builtin_ArrayShift
       750   0.1% v8::internal::Runtime_StringSplit
       737   0.1% v8::internal::Factory::NewProperSubString
            [...]

We seem to lose a lot of time in the store buffer.

Adding the experts for this on CC :)


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to