mirror of https://github.com/vuejs/core.git
perf(ssr): avoid calling markRaw on component instance proxy
The previous behavior invokes the definePropery proxy trap on the instance proxy and has massive overhead. This change improves Vue ops/sec by 40% in https://github.com/eknkc/ssr-benchmark
This commit is contained in:
parent
34106bc9c7
commit
4bc9f39f02
|
@ -775,8 +775,7 @@ function setupStatefulComponent(
|
||||||
// 0. create render proxy property access cache
|
// 0. create render proxy property access cache
|
||||||
instance.accessCache = Object.create(null)
|
instance.accessCache = Object.create(null)
|
||||||
// 1. create public instance / render proxy
|
// 1. create public instance / render proxy
|
||||||
// also mark it raw so it's never observed
|
instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers)
|
||||||
instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers))
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
exposePropsOnRenderContext(instance)
|
exposePropsOnRenderContext(instance)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import {
|
||||||
isString,
|
isString,
|
||||||
} from '@vue/shared'
|
} from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
|
ReactiveFlags,
|
||||||
type ShallowUnwrapRef,
|
type ShallowUnwrapRef,
|
||||||
TrackOpTypes,
|
TrackOpTypes,
|
||||||
type UnwrapNestedRefs,
|
type UnwrapNestedRefs,
|
||||||
|
@ -307,6 +308,10 @@ const hasSetupBinding = (state: Data, key: string) =>
|
||||||
|
|
||||||
export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
||||||
get({ _: instance }: ComponentRenderContext, key: string) {
|
get({ _: instance }: ComponentRenderContext, key: string) {
|
||||||
|
if (key === ReactiveFlags.SKIP) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
const { ctx, setupState, data, props, accessCache, type, appContext } =
|
const { ctx, setupState, data, props, accessCache, type, appContext } =
|
||||||
instance
|
instance
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue