Closed Bug 1056260 Opened 10 years ago Closed 15 days ago

Improve performance of [...obj] and Array.from

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bzbarsky, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached file Testcase
See attached testcase.  slice.call() is way faster than the more idiomatic things.

Two issues here:

1)  slice.call() does not need to do all the iterator jazz.
2)  slice has a fast path for nodelists where it only calls a single proxy hook
    and has it fill in the list.

It'd be nice if we could improve both of those for Array.from and destructuring...
There may be relevant lessons in bug 904723, which was something of a slog.

The first step should be to measure improvement due to nbp's work on escape analysis and alias anlysis (see bug 927548 "scalar replacement").
Blocks: dom-requests
Firefox 53.0.3
Time to slice live nodelist: 0.411ms
Time to destructure live nodelist: 0.268ms
Time to Array.from live nodelist: 0.562ms

Time to slice static nodelist: 0.3955ms
Time to destructure static nodelist: 0.248ms
Time to Array.from static nodelist: 0.5525ms

Time to slice array: 0.0215ms
Time to destructure array: 0.107ms
Time to Array.from array: 0.3455ms


Nightly 55 (23-05-2017)
Time to slice live nodelist: 0.417ms
Time to destructure live nodelist: 0.216ms
Time to Array.from live nodelist: 0.214ms

Time to slice static nodelist: 0.38ms
Time to destructure static nodelist: 0.197ms
Time to Array.from static nodelist: 0.1835ms

Time to slice array: 0.021ms
Time to destructure array: 0.069ms
Time to Array.from array: 0.055ms

Improvement from bug 1366372?
Severity: normal → S3

Nightly:

Time to slice live nodelist: 0.015ms
Time to destructure live nodelist: 0.0385ms
Time to Array.from live nodelist: 0.0375ms

Time to slice static nodelist: 0.013ms
Time to destructure static nodelist: 0.0365ms
Time to Array.from static nodelist: 0.0425ms

Time to slice array: 0.0005ms
Time to destructure array: 0.007ms
Time to Array.from array: 0.0065ms

Chrome:
Time to slice live nodelist: 0.106ms
Time to destructure live nodelist: 0.1345ms
Time to Array.from live nodelist: 0.133ms

Time to slice static nodelist: 0.1265ms
Time to destructure static nodelist: 0.127ms
Time to Array.from static nodelist: 0.124ms

Time to slice array: 0ms
Time to destructure array: 0.0005ms
Time to Array.from array: 0ms

We are faster in almost all the cases. Calling this fixed.

Status: NEW → RESOLVED
Closed: 15 days ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: