Closed Bug 1923996 Opened 2 years ago Closed 2 months ago

Vue's createReactiveObject is 2.8x slower in SM than V8 due to StoreBuffer overhead in WeakMap.set

Categories

(Core :: JavaScript Engine: JIT, defect, P2)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mstange, Unassigned)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [sp3])

This bug is very similar to bug 1900466, but this bug is about the WeakMap.set part, not about the proxy creation part.

We spend 3x as much time as Chrome inside WeakMap.set. This shows up on Sp3-Vue-TodoMVC and Sp3-NewsSite-Nuxt. On both tests making Firefox as fast as Chrome on this function would reduce the overall runtime of this subtest in Firefox by 0.6%.

It's possible that WeakMap.set is slower today than when bug 1900466 was filed.

Chrome: https://share.firefox.dev/4h2PRys (211 samples in Builtins_WeakMapPrototypeSet)
FF: https://share.firefox.dev/3No7qv8 (648 samples in WeakMapObject::set)

function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
            if (!(0, _vue_shared__WEBPACK_IMPORTED_MODULE_1__.Kn)(target)) {
                if (false) {}
                return target;
            }
            if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) {
                return target;
            }
            const existingProxy = proxyMap.get(target);
            if (existingProxy) {
                return existingProxy;
            }
            const targetType = getTargetType(target);
            if (targetType === 0) {
                return target;
            }
            const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
            proxyMap.set(target, proxy);
            return proxy;
        }
Blocks: sm-runtime
Severity: -- → S4
Priority: -- → P2

Jon, is this something you could look at? Is the StoreBuffer part new?

Flags: needinfo?(jcoppeard)
Whiteboard: [sp3] → [sp3][js-perf-next]

This seems worth investigating, but I don't think we have a clear enough idea of what's going on or how we would fix it to mark it as js-perf-next.

Whiteboard: [sp3][js-perf-next] → [sp3]

Is this still slow after the work done in bug 1821107 and dependents?

Comparing equivalent profiles of SP3, I see 245 samples in SM vs 414 samples in V8. So it's certainly plausible that something under bug 1821107 helped, although I'm not sure exactly what.

We're spending less time in WeakMap::set than V8, and I don't see createReactiveObject in comparison reports. I'm closing this.

Status: NEW → RESOLVED
Closed: 2 months ago
Flags: needinfo?(jcoppeard)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.