by mmastrac · 3y ago · 0 comments
Exception handler structures can dramatically change performance characteristics of code. async/await is a real crapshoot -- sometimes promises are faster, sometimes async blocks are.
We can blame the poor specs for some slowdowns (why does `...` destructuring use iterators??), but I wonder if the v8 team is chasing benchmarks at the expense of real-world code that might not be so perfectly written.
If you couldn't use the iterator protocol, generators in particular would be a lot less powerful
[a, b, ...rest] = array
is implemented like this: a = array[0]
b = array[1]
rest = array[2...]
When instead it is a giant performance footgun to the point where it should only be used outside of performance critical code.EDIT "next -> rest"
Fundamentally, it's the same thing that impedes most optimizations: there are hundreds of different patterns we could optimize, it takes a fair bit of thought to get it right, and we have finite resources, so we have to pick and choose. This particular pattern turns out to be idiomatic in a lot of React code, which is why we're looking at it now. (Or so people tell me; most JS I write is gross little testcases.)
They aren't. V8's benchmark performance for this benchmark has been stagnant because they haven't cared about it for a long time. Firefox has an incentive to care about it (unfortunately) because even when a benchmark doesn't matter it still looks bad to be behind on it.
(Speedometer is the benchmark that most closely approximates messy real-world code.)
Isn't it the other way around? https://v8.dev/blog/real-world-performance
I recall there was some newer blogpost discussing this topic with numbers and examples but can't find it atm, maybe it was chromium/chrome team blog, maybe someone else can find it.