substring shows up in Preact profiles

NEW
Unassigned

Status

()

Core
JavaScript Engine
P3
normal
6 months ago
2 months ago

People

(Reporter: Away for a while, Unassigned)

Tracking

(Blocks: 1 bug, {perf})

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [qf:p3])

Attachments

(1 attachment)

(Reporter)

Description

6 months ago
Created attachment 8878849 [details]
reduced test case

Profile: http://bit.ly/2sKUasZ
Test case: http://speedometer2.benj.me/InteractiveRunner.html?suite=Preact-TodoMVC

The time spent here is under Adding100Items.  It's not that much but perhaps something to look into.  This is the code where the call comes from:

function y(e, t, n, o, r) {
    if ("className" === t && (t = "class"), "class" === t && o && "object" === (void 0 === o ? "undefined" : fe(o)) && (o = a(o)), "key" === t);
    else if ("class" !== t || r)
        if ("style" === t) {
            if ((!o || l(o) || l(n)) && (e.style.cssText = o || ""), o && "object" === (void 0 === o ? "undefined" : fe(o))) {
                if (!l(n))
                    for (var s in n) s in o || (e.style[s] = "");
                for (var c in o) e.style[c] = "number" != typeof o[c] || se[c] ? o[c] : o[c] + "px"
            }
        } else if ("dangerouslySetInnerHTML" === t) e.innerHTML = o && o.__html || "";
    else if ("o" == t[0] && "n" == t[1]) {
        var u = e._listeners || (e._listeners = {});
        t = $(t.substring(2)), o ? u[t] || e.addEventListener(t, g, !!ce[t]) : u[t] && e.removeEventListener(t, g, !!ce[t]), u[t] = o
    } else if ("list" !== t && "type" !== t && !r && t in e) b(e, t, null == o ? "" : o), null != o && o !== !1 || e.removeAttribute(t);
    else {
        var f = r && t.match(/^xlink\:?(.+)/);
        null == o || o === !1 ? f ? e.removeAttributeNS("http://www.w3.org/1999/xlink", $(f[1])) : e.removeAttribute(t) : "object" === (void 0 === o ? "undefined" : fe(o)) || i(o) || (f ? e.setAttributeNS("http://www.w3.org/1999/xlink", $(f[1]), o) : e.setAttribute(t, o))
    } else e.className = o || ""
}


On this reduced test case (I didn't bother looking up the name of the actual event handlers that flow through this code), Nightly gets ~3700 on my machine, Chrome unstable gets ~2800.
The self-hosted "Substring()" function also shows up in the Speedometer Backbone benchmark, where we inline it 1522 times. That function just does some basic Int32 coercion and calls SubstringKernel(), which we already know how to inline.

At least for that case, it would be good to teach Ion how to inline Substring() directly as a Native.

Updated

6 months ago
Whiteboard: [qf:p3]
It seems we could kill Substring completely and do the coercion in SubstringKernel.
Priority: -- → P3
Keywords: perf
You need to log in before you can comment on or make changes to this bug.