Open Bug 1733645 Opened 3 years ago Updated 2 years ago

[Speedometer] $digest from AngularJS-TodoMVC takes 2x-4x longer than chrome

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

People

(Reporter: denispal, Unassigned)

References

(Blocks 1 open bug)

Details

This function is called quite often, and is likely a big reason we are behind in this subtest.

Here is a zoomed in profile from Chrome & Firefox for one call instance:

Chrome: https://share.firefox.dev/39TSEID
Firefox: https://share.firefox.dev/2Y4tggM

Overall for the whole suite, we spend 1,116ms in $digest while Chrome spends 736ms.

The function is defined at https://browserbench.org/Speedometer2.0/resources/todomvc/architecture-examples/angularjs/node_modules/angular/angular.min.js:146:410

                $digest: function() {
                    var a, g, h, l, m, q, p, F = b,
                        y, u = [],
                        v, x;
                    n("$digest");
                    k.$$checkUrlChange();
                    this === A && null !== e && (k.defer.cancel(e),
                        w());
                    c = null;
                    do {
                        p = !1;
                        y = this;
                        for (q = 0; q < t.length; q++) {
                            try {
                                x = t[q], l = x.fn, l(x.scope, x.locals)
                            } catch (z) {
                                f(z)
                            }
                            c = null
                        }
                        t.length = 0;
                        a: do {
                            if (q = y.$$watchers)
                                for (q.$$digestWatchIndex = q.length; q.$$digestWatchIndex--;) try {
                                    if (a = q[q.$$digestWatchIndex])
                                        if (m = a.get, (g = m(y)) !== (h = a.last) && !(a.eq ? sa(g, h) : ba(g) && ba(h))) p = !0, c = a, a.last = a.eq ? Ia(g, null) : g, l = a.fn, l(g, h === r ? g : h, y), 5 > F && (v = 4 - F, u[v] || (u[v] = []), u[v].push({
                                            msg: E(a.exp) ? "fn: " + (a.exp.name || a.exp.toString()) : a.exp,
                                            newVal: g,
                                            oldVal: h
                                        }));
                                        else if (a === c) {
                                        p = !1;
                                        break a
                                    }
                                } catch (B) {
                                    f(B)
                                }
                            if (!(q =
                                    y.$$watchersCount && y.$$childHead || y !== this && y.$$nextSibling))
                                for (; y !== this && !(q = y.$$nextSibling);) y = y.$parent
                        } while (y = q);
                        if ((p || t.length) && !F--) throw A.$$phase = null, d("infdig", b, u);
                    } while (p || t.length);
                    for (A.$$phase = null; D < s.length;) try {
                        s[D++]()
                    } catch (G) {
                        f(G)
                    }
                    s.length = D = 0;
                    k.$$checkUrlChange()
                }
Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.