Press play or click any turn in the transcript to start real-time synchronized playback...
Hi, it's Mike with UGtastic . I'm here at GOTO Conference 2015, and I'm sitting here with Vyacheslav Egorov, who gave a talk on benchmarking JS. Hi, it's Mike with UGtastic . I'm here at GOTO Conference 2015, and I'm sitting here with Vyacheslav Egorov, who gave a talk on benchmarking JS. JavaScript performance is a critical aspect of web development. Vyacheslav Egorov explains why many benchmarks are incorrect and provides insights into optimizing your JavaScript code.
Hi, it's Mike with UGtastic . I'm here at GOTO Conference 2015, and I'm sitting here with Vyacheslav Egorov, who gave a talk on benchmarking JS. Thank you very much for taking the time to speak with me. When you talk about benchmarking JS, are you talking about client-side JS?
So, I don't have any particular focus. I'm just looking at the pure JavaScript performance. So, it doesn't matter if you run your JavaScript on the client-side or server-side. Basically, no matter where you are, my talk applies to you.
So, you know, even if I'm in V8 or Rhino or whatever, it's going to be...
Mike HallInterviewer, UGtastic▶ Speaking
Okay, so, when you talk, what techniques and tools were you talking about? Where did this talk come from? What experiences did you have that led you to this?
Well, I used to work on the V8 team, and when you work on a team of the VM engineers, you usually get different questions from the users, in this case, JavaScript developers, who don't completely understand what happens inside the VM and how they should measure performance of their code. And that's what this talk is based on. Basically, I monitor different social media, and I see people posting different benchmarks, and I look what happens there, and I explain why these benchmarks are usually incorrect. And that's, yeah, that's basically my experience.
Mike HallInterviewer, UGtastic▶ Speaking
So, what are some of the things that you see that are incorrect, and like, what are some quick tips, or articles people should read or try to understand better about JavaScript performance?
I think the biggest issue is that people still think that JavaScript implementations are very dumb, but these implementations are quite smart. So, I think that that's the main thing that they should know about that, and they should always account for the very advanced optimizations that the JS engines are capable of doing now. So, there is no really single tip. They should just try to understand what is happening on the inside.
Mike HallInterviewer, UGtastic▶ Speaking
Okay.
Mike HallInterviewer, UGtastic▶ Speaking
Now, if you're dealing with V8 optimization, one of the things is that JavaScript runs anywhere, on V8, Rhino, different browsers. Does the wisdom of "this is good for JavaScript performance" apply generally everywhere? Or do you find people benchmarking on V8, and then when they try a different VM they see very different performance characteristics?
Sometimes that happens, but these days, the implementations really converge on, they apply the same techniques, so it's quite often that you see the same performance characteristics across all of the platforms you use. That's why this talk is quite universal, and this issue is quite universal.
Mike HallInterviewer, UGtastic▶ Speaking
Okay, and when you're looking at the way JavaScript is being implemented, I mean, I've heard people on Twitter tweeting about, you know, if you're trying to implement a class structure in JavaScript, don't reimplement the classical inheritance structure, use the prototypal inheritance and different ways of structuring your application. Does that play into the way people reason about writing JavaScript, and its performance? If I'm implementing a class in JavaScript, is that generally gonna perform worse or better than if I do something more native?
So the thing is that JavaScript engines evolve naturally, so they follow the paths that people are using, so they optimize for the patterns that people are using. In this sense, if you use, for example, constructors and prototypes, this is actually the most performant way of writing JavaScript, especially if you keep everything, like, kind of static. Yeah, you just follow the common patterns and then you will be safe.
Mike HallInterviewer, UGtastic▶ Speaking
Okay, and as far as working on the V8 engine itself, I didn't realize it before our conversation. How did you get involved in working on V8, which has become something of an industry change? Not just with Chrome, but with Node being built on that. You're working on some pretty intense technology.
So, well, I stopped working on V8 three years ago, but I was doing the Java VM before back in Russia, and then V8 people were searching for a person with a compiler background, and they hired me, so I joined the team. I worked on different parts of V8, from garbage collection to compiler infrastructure. So I have the background in this, and that background seems to fit with what the team needed.
Mike HallInterviewer, UGtastic▶ Speaking
Right. Okay, you described two things earlier. One is that JavaScript implementations are much smarter than people give them credit for, and that the current patterns of how people write their applications are being used to derive how these JS VMs work. Is there something, a common pattern that people are using, that you kind of wish they would just move away from? Like, even though we have classical class and inheritance, but if they wrote their JavaScript a different way, it would be a lot more efficient?
No, I actually have an opposite issue. So, the, the JavaScript VMs, even though they are quite smart, they still, because they evolve by following what people do, they are very focused. So, what I really want them to do is to start expanding this area of fast JavaScript and support, like, different corners of the language they do not support well, or they just fall to the slow path, and so on. So, it's actually the other way around.
Yeah. Yeah. So you are a little bit frustrated with it, like, "Hey, we're just going to do this one type of structure, but JavaScript is so much more than that."