Issue 2392 in v8: Array: big performance difference when creating big array from empty or single-element array

7 views
Skip to first unread message

codesite...@google.com

unread,
Nov 3, 2012, 10:10:56 PM11/3/12
to v8-...@googlegroups.com
Status: New
Owner: ----

New issue 2392 by i...@bnoordhuis.nl: Array: big performance difference
when creating big array from empty or single-element array
http://code.google.com/p/v8/issues/detail?id=2392

Tested with ia32 and x64 builds of the current bleeding_edge HEAD, r12842.
The numbers posted here are from the x64 build. The ia32 numbers are
comparable albeit slightly better.

$ cat tmp/big-array/1.js
for (var a = [], i = 0; i < 64*1024*1024; ++i) a.push(123.456);

$ time out/native/d8 tmp/big-array/1.js
real 0m3.672s
user 0m3.176s
sys 0m0.452s

$ cat tmp/big-array/2.js
for (var a = [123.456], i = 0; i < 64*1024*1024; ++i) a.push(123.456);

$ time out/native/d8 tmp/big-array/2.js
#
# Fatal error in CALL_AND_RETRY_0
# Allocation failed - process out of memory
#

Trace/breakpoint trap (core dumped)

real 0m52.356s
user 0m51.995s
sys 0m0.416s

As a gist: https://gist.github.com/4009799

It's not all bad, though. Array concatenation is fast, impressively so.

$ cat tmp/big-array/3.js
for (var a = [123.456], i = 0; i < 26; ++i) a = a.concat(a);

$ time out/native/d8 tmp/big-array/3.js
real 0m1.664s
user 0m1.468s
sys 0m0.192s

codesite...@google.com

unread,
Nov 5, 2012, 6:02:27 AM11/5/12
to v8-...@googlegroups.com
Updates:
Owner: verwa...@chromium.org

Comment #1 on issue 2392 by verwa...@chromium.org: Array: big performance
difference when creating big array from empty or single-element array
http://code.google.com/p/v8/issues/detail?id=2392

I'm already working on this; this code should see improvements pretty soon.

codesite...@google.com

unread,
Nov 5, 2012, 6:03:27 AM11/5/12
to v8-...@googlegroups.com
Updates:
Status: Accepted

Comment #2 on issue 2392 by verwa...@chromium.org: Array: big performance
difference when creating big array from empty or single-element array
http://code.google.com/p/v8/issues/detail?id=2392

(No comment was entered for this change.)

codesite...@google.com

unread,
Nov 15, 2012, 11:18:28 AM11/15/12
to v8-...@googlegroups.com
Updates:
Status: Fixed

Comment #3 on issue 2392 by verwa...@chromium.org: Array: big performance
difference when creating big array from empty or single-element array
http://code.google.com/p/v8/issues/detail?id=2392

It still goes out of memory, but now it does so after ~0.5s, whereas the
concat code goes out of memory after ~0.25s. Performance wise this is fixed.

Reply all
Reply to author
Forward
0 new messages