Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
perf($compile): wrap try/catch of collect comment directives into a function to avoid V8 deopt #14848
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) its a performance optimization. It turns out that try/catch statements prevents the optimization of the function collectDirectives, which has a great weight in the initial document parse.
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change?
Please check if the PR fulfills these requirements
I did all performance checking over existing code from my customers, in their code this optimization makes it go a 5% faster in the initial parse time and compile time in average (I just performed 200 evaluation comparison with execution times around 50 - 100ms of each evaluation). I did the performance test over chrome, safari and firefox, all of them with similar speedup results.
It should solve it, because in production environments usually there are no comments, so, this function is likely to be never executed.
I did no new documentation neither new tests because nothing changes but performance.
Great PR, thanks for this. Could you add a comment to the function that indicates that this is for perf reasons?
Funnily enough, the try-catch was introduced because there was a not reproducible error in IE9 ...