New issue
Advanced search Search tips
Starred by 2 users
Status: Assigned
Owner:
Cc:
Components:
HW: All
OS: All
Priority: 2
Type: Bug
ES5

Blocking:
issue 6936



Sign in to add a comment
High overhead of C++ Array builtins in CoffeeScript
Project Member Reported by bmeu...@chromium.org, Oct 23 Back to list
The coffeescript test in the web-tooling-benchmark shows a high percentage of time spent in C++ Array code, specifically Array#slice and Array#concat. There are probably a couple of low hanging fruits to pick here.


 
coffeescript.json
7.3 MB View Download
wtb-coffeescript.js
3.0 MB View Download
wtb-coffeescript.png
256 KB View Download
Project Member Comment 1 by bugdroid1@chromium.org, Oct 24
The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/6452b26a4bd746928937124d674e6dc3b9031396

commit 6452b26a4bd746928937124d674e6dc3b9031396
Author: Daniel Clifford <danno@chromium.org>
Date: Tue Oct 24 06:39:47 2017

Reimplement Array.prototype.slice in CSA and C++

Previously, V8's slice was implemented in a combination of C++ and a 
Javascript fallback. The disadvantage of this approach was that the
fast-path required a call through the CEntryStub, which introduced
considerable overhead for small arrays with fast elements kinds.

Now the implementation primarily uses the CSA to generate both the
full spec-complaint implementation as well as fast paths for argument
objects and arrays with fast elements kinds. The CSA implementation
uses a C++ implementation fallback in select situations where the the
complexity of a CSA implementation would be too great and the
CEntryStub overhead is not decisive (e.g. slices of dictionary
elements arrays).

Performance results on semi-random arrays with small number of
elements (old vs. new):

smi copy: 48.7 ms vs. 12 ms
smi slice: 43.5 ms 14.8 ms
object copy: 35.5 ms 7.7 ms
object slice: 38.7 ms 8.8 ms
dictionary slice: 2398.3 ms vs. 5.4 ms
fast sloppy arguments slice: 9.6 ms vs. 7.2 ms
slow sloppy arguments slice: 28.9 ms vs. 8.5 ms

As a bonus, the new implementation is fully spec-compliant and fixes
at least one existing bug.

The design document for Array.prototype builtin rework can be found
at https://goo.gl/wFHe2n

Bug: v8:1956,v8:6601,v8:6710,v8:6978
Change-Id: Ia0155bedcf39b4577605ff754f416c2af938efb7
Reviewed-on: https://chromium-review.googlesource.com/574710
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48853}
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/bootstrapper.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/builtins/builtins-array-gen.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/builtins/builtins-definitions.h
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/code-factory.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/code-factory.h
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/code-stub-assembler.h
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/debug/debug-evaluate.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/elements.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/flag-definitions.h
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/runtime/runtime-array.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/src/runtime/runtime.h
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/test/cctest/compiler/test-run-stubs.cc
[modify] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/test/mjsunit/mjsunit.status
[add] https://crrev.com/6452b26a4bd746928937124d674e6dc3b9031396/test/mjsunit/splice-proxy.js

The CL https://chromium-review.googlesource.com/574710 by danno@ improves the coffeescript test by around 4%, so roughly half the overhead of Array#slice is gone.

Now Array#concat and Array#push are dominating wrt. Array builtins.
wtb-coffeescript.png
323 KB View Download
Sign in to add a comment