Closed Bug 1422726 Opened 7 years ago Closed 7 years ago

Optimize NativeObject::addEnumerableDataProperty

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
addEnumerableDataProperty is one of the hottest functions on Speedometer and adding new properties to objects is still slower than it should be. The attached patch adds a fast path to addEnumerableDataProperty for non-dictionary objects that have a single kid shape that matches the new property. This fast path hits most of the time on both Octane and Speedometer. For the micro-benchmark below I get the following, best of 5 runs: before: 945 ms after: 811 ms It also improves six-speed's object-assign-es6 test from 237 ms to 208 ms. There's more to optimize here but this is a good start. function g(a) { var o = {}; for (var i = 0; i < a.length; i++) { o[a[i]] = i; } return o; } function f() { var arr = ["a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"]; var t = new Date; for (var i = 0; i < 1000000; i++) res = g(arr); print(new Date - t); } f();
Attachment #8934135 - Flags: review?(bhackett1024)
Oops, that micro-benchmark is wrong, the numbers are for this slightly simpler one: function f() { var arr = ["a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"]; var t = new Date; for (var i = 0; i < 1000000; i++) { res = {}; for (var j = 0; j < arr.length; j++) { res[arr[j]] = i; } } print(new Date - t); } f();
Attachment #8934135 - Flags: review?(bhackett1024) → review+
Pushed by jandemooij@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/10aa5c0593fa Optimize addEnumerableDataProperty by adding a fast path for the most common case. r=bhackett
Priority: -- → P3
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: