RubyConf 2015

Cómo funciona por dentro la máquina virtual de Ruby

Aaron Patterson  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

- Hey, we should start now, because it is time to do that. One sec, let me take a photo. I've gotta use this selfie stick. Alright, alright, alright. Thank you, thank you. So I just want to say thanks to Justin for giving that really incredible talk earlier.

It was actually really good, so everybody give him a round of applause. It's definitely the talk that we all want our coworkers to watch. All the ones that are not here and not watching the live stream. Anyway, so before I get started I want you to know that me, Justin, and Gary, we all met before RubyConf and we swapped all of our slides, so I'm going to be giving -- like, Justin did a really good job, but that was my presentation that he gave.

I'm going to be giving either his talk or Gary's talk. I'm not sure which one yet. I haven't actually seen the slides, so please, please bear with me. Alright, so let's try to do this. Okay. So, JavaScript. I'm not sure whose talk this is yet. Could be Gary's, could be Justin's.

Okay, let's see. Let's go to the next slide and see what that is. I can't tell, I really can't tell. Alright, alright, let's get to some serious business. This talk is called Ruby VM Internals The TMI Edition. My name is Aaron Patterson. You know me on the internet as tenderlove.

If you don't recognize me, like I look different than I do online, this is what I look like online, in case you don't recognize me here. This is my cat, Gorbachev Puff-Puff Thunderhorse. I've got stickers of him, so if you'd like a sticker, you can come say hello to me and I will give you a sticker of him.

This is my other cat, SEA-TAC. SEA-TAC, Facebook, YouTube, Instagram. That's her name. We call her choo choo. We also have a sticker of her now, finally, so you can get that one too. I'm on the Ruby Core Team and I'm on the Rails Core Team. This doesn't mean that I know what I'm talking about, it just means that I'm very bad at saying "no".

This is very true. So, I work at redhat. I'm an engineer at redhat. I'm on the ManageIQ team, and we build an open source application that manages clouds, so if you have a cloud at your work we can manage it with our software. We manage anything from regular clouds to rainy clouds to snowing clouds.

All of these, we can manage those. And the application is open source so you can go check it out here on the GitHubs. I signed up for the RubyConf 5k. Anyone else do this? So, I signed up by accident. I thought it was a retirement plan. It turns out it's just a bunch of people who are going to run.

And there's literally no point, it's just a run. Anyway, I'm really, really excited to be here in Texas. It's a really great place, I'm glad to be here in San Antonio. I'm excited to be here in San Antonio because I heard that San Antonio is really famous for ice cream.

I don't know if you know this. They're famous for ice cream. So my wife and I arrived last night and we went to dinner and I decided to order dessert and I wanted to get pie. There was no pie emoji, so I just put a pizza pie in there. So I wanted to get a pie, but I was afraid that the waiter might forget the ice cream, so I said to him, "Remember the a la mode.

" I've been laughing at that one all day. Like, "Hey Ebi, listen to this, listen to this. "I'm gonna say this in my talk. "No, really. " Alright. Okay. So let's do this, let's do this for real. Alright. I was gonna name this talk Stupid Ruby VM Tricks, but then I realized that the tricks aren't very stupid, so that didn't make sense.

And then they're also not tricks. So it was just Ruby VM. So I'm going to talk about Ruby's Virtual Machine and its internals. And in case you can't tell, I'm very, very nervous. I've never given this talk before, and so I'm scared. But we will get through this together, and the upshot is that I'm right before lunch, so if I end too quickly, everyone will be happy, we get to go to lunch anyway.

Also, this is the very first day, so by the end of the conference, everyone will have forgotten about my talk, so it doesn't matter how poorly I did anyway. Plus I probably also won't die on stage. Hopefully. Though if I did die, I would be dead and it wouldn't matter how bad I did.

So, warning, warning, this is a tech talk. There is actually a lot of code in here. I apologize in advance. There will be code, and not all of it will be Ruby. Much of it will actually be C code, so I'm sorry. So we're gonna talk about Ruby's Virtual Machine.

We're gonna talk about its internals. And this is true, except that this talk is actually a talk about failure and how I failed. I decided that I would try to write an ahead of time compiler. I thought that would be really really fun, I'm gonna do that, and I failed at doing that.

So this talk is going to be about that, the things that I learned on my way, and I don't think it's actually a failure, I'm just not finished yet, so I want to rebrand failure as "potential for success". So, it's there, it's going, I know how to do it, it's just not done yet.

But I also thought, I really think data analysis is kind of a cool thing, although after this morning's keynote I'm worried about the data analysis that I did. I decided to do a time break down of my feeling of being successful. Like, when do I feel successful? I decided to log all that and figure it out.

So I've actually broken that down into a pie chart, and this is what it looks like. And you can tell that this pie chart is legit because one of the pie pieces is actually extracted, and moved outside so you know that this is for real here. Anyway, so it says I failed, but at least I learned something, right? Right? I learned something.

Does that matter? The answer: no. Alright, so let's dive in, let's dive into this. As I was thinking about this, I was thinking,alright. We're going to do some ahead of time compiling. What does it mean when we do ruby and myprogram, we said Ruby, run myprogram.

What does that mean? So I was sitting there thinking about it. I'm like well, okay. So when we think about running a Ruby program, we can actually break that down into two distinct steps. There's two distinct things that happen when you run a Ruby program, and these are the two things.

The stuff that happens before the program runs, and then running the actual program. Those are our two distinct things there. And you'll notice that one thing naturally goes to the other. We say okay, well the stuff that happens before the program runs, that happens before running the program.

Then we run the actual program, and then the program goes. But this is actually a loop, too. I'm using some funny terminology here but there is a grain of truth to this. So we say like, okay, well there's some stuff that happens before the program runs, like parsing, compiling, etc.

and then we run the actual program. And this actually happens in a loop. If you think about it, anytime you do eval, which you're not doing in your code, please don't write eval in your code. But if you do do eval, you're essentially going back to the beginning of this thing here, as well, right? You're doing that, you may be doing this in a loop over and over, whatever it is, depending on your program.

Now, if we think about the actual details in what these two steps are we have, on the left here we have the Lexer, Compiler, Parser, and on the right side we have the Virtual Machine. And I don't really want to talk about the lexer and parser. I'm gonna dedicate about two slides each to those things.

[ ... ]

Nota: se han omitido las otras 3.610 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.