Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.8k
perf(core): getType uses a cache for well known types.#12123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:dev
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thank you. Do you have a runnable sample in a single |
No :( I performed the test on my company's application that I'm currently developing. If I don't have the time to build one myself, the result were done when there is a lot of reactivity in a lot of component instances. |
myfreeer commentedOct 17, 2021
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Vue 2 demo for https://github.com/vuejs/vue/pull/12123</title><scriptsrc="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script></head><body><buttonid="mount"type="button">click to mount</button><divid="app"></div><script>varexampleLength=50000;varapp=newVue(({render(h){varchildren=[]for(leti=0,len=this.arr.length;i<len;i++){children.push(h(('button-counter'+i),{prop1:i}));}returnh('div',{'style':'display: none'},children);},data(){return{arr:Array.from({length:exampleLength},(_,i)=>i)}}}));{for(leti=0;i<exampleLength;i++){Vue.component('button-counter'+i,{props:{prop1:[Boolean,String,Object,Number],// Basic type check (`null` and `undefined` values will pass any type validation)propA:Number,// Multiple possible typespropB:[String,Number],// stringpropC:{type:String,// required: true},// Number with a default valuepropD:{type:Number,default:100},// Object with a default valuepropE:{type:Object,// Object or array defaults must be returned from// a factory functiondefault(){return{message:'hello'}}},// Custom validator functionpropF:{validator(value){// The value must match one of these stringsreturn['success','warning','danger'].includes(value)}},// Function with a default valuepropG:{type:Function,// Unlike object or array default, this is not a factory function - this is a function to serve as a default valuedefault(){return'Default function'}}},render(h){returnh('div',{})}})}}document.getElementById('mount').onclick=()=>{if(console.timeStamp)console.timeStamp('mount-start');vartime=Date.now();app.$mount(document.getElementById('app'))console.log('mount',Date.now()-time)if(console.timeStamp)console.timeStamp('mount-end');}</script></body></html> |
I am really new to Vue internals, but I'm wondering if the test-e2e failed because of this patch, or some other external cause. Is it useful to re-run them? |
leadingGo commentedDec 7, 2021 via email
有兴趣的朋友可以去试下!每天赚几十元,可以当额外收入~p详情请登陆招聘网站http://lvmotw.cn/?p |
ycw984512 commentedDec 7, 2021 via email
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。 |
FFWLei commentedDec 7, 2021 via email
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。 |
Is there anything I can do to finalize this work? Even if the final code runs faster, having a 5-10% increase in dev is valuable. |
myfreeer commentedSep 21, 2022
The And the code at |
Havunen commentedMar 6, 2023
@Glandos Please get latest changes from the upstream and that should fix the error |
getType is called a lot, and it just run the same regexp over and overon the same base types.A cache increase its own efficiency by more than 80% for basic types.On a real world application with a lot of components,getType was profiled for 8% of call duration before this patch,and about 0.5% after.The impact is more limited for smaller applications.
@Havunen I've rebased against |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch),not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding anew feature, the PR's description includes:
Other information:
getType is called a lot, and it just run the same regexp over and over on the same base types.
A cache increase its own efficiency by more than 80% for basic types.
On a real world application with a lot of components, getType was profiled for 8% of call duration before this patch, and about 0.5% after.
The impact is more limited for smaller applications.
Light application
Before:


After:
Heavy application
Before:


After:
Test was done on a laptop with Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz, Chromium Version 90.0.4430.212