Performance

Summarized using AI

Opening Keynote: Make Rails Great Again

Aaron Patterson • May 04, 2016 • Kansas City, MO

The video titled "Opening Keynote: Make Rails Great Again" features Aaron Patterson, a prominent software engineer known as "Tenderlove" in the programming community. This keynote, delivered at RailsConf 2016, discusses the current state of Ruby on Rails and highlights Patterson's aspirations for its future development. The talk is marked with humor, personal anecdotes, and technical insights.

Main Topics Discussed:

- Introduction to Aaron Patterson: Patterson provides a brief introduction of himself, mentioning his roles within the Ruby and Rails core teams and his recent position at GitHub.

- Career Reflections: He shares a personal journey about his career goals, expressing a desire to contribute meaningfully to Rails rather than pursuing riches. He humorously states he wants to be a "cog" in the GitHub machine, emphasizing collaboration over competition.

- Rails 5 Improvements: Patterson announces significant advancements in Rails 5. He portrays Rails as being "in its prime" and discusses new threading features, Active Record updates, and Rails appealing to startups.

- Performance Optimization: Performance is a key theme, where Patterson explains trade-offs involved in development, particularly the emphasis on boot time performance and how RubyGems can impact startup time negatively.

- PHP Integration Announcement: In a humorous twist, he teases support for PHP template integration with Rails, playfully suggesting collaboration with the PHP community to enhance Rails' attractiveness to startups.

- Key Lessons for Developers: Patterson concludes with essential takeaways for developers on performance measurement and the importance of continuous improvement in the Ruby and Rails ecosystems.

Significant Examples and Anecdotes:

- Patterson shares his early career desires and how they evolved.

- He interacts with humor about his preferences for programming styles and performances, including references to pop culture and his cats.

Conclusions and Takeaways:

- The emphasis on improving Rails should focus on collaboration, openness to new ideas (like PHP integration), and continuous performance enhancements.

- Developers are encouraged to consider the impacts of their code on performance and prioritize efficient practices to ensure a robust ecosystem.

Opening Keynote: Make Rails Great Again
Aaron Patterson • May 04, 2016 • Kansas City, MO

Aaron was born and raised on the mean streets of Salt Lake City. His only hope for survival was to join the local gang of undercover street ballet performers known as the Tender Tights. As a Tender Tights member, Aaron learned to perfect the technique of self-defense pirouettes so that nobody, not even the Parkour Posse could catch him. Between vicious street dance-offs, Aaron taught himself to program. He learned to combine the art of street ballet with the craft of software engineering. Using these unique skills, he was able to leave his life on the streets and become a professional software engineer. He is currently Pirouetting through Processes, and Couruing through code for GitHub. Sometimes he thinks back fondly on his life in the Tender Tights, but then he remembers that it is better to have Tender Loved and Lost than to never have Tender Taught at all.

RailsConf 2016

00:00:09.590 Welcome to our first morning keynote this morning, and that is Aaron Patterson.
00:00:15.480 Aaron loves hugs.
00:00:23.150 Oh, one second, I need to do this real quick.
00:00:32.960 All right, for posterity, thank you, thank you. No, I'll give you a hug, but only in person, okay? Okay, time for me to turn into a nervous wreck.
00:01:01.660 Should I start dropping f-bombs now? Is this it? Ah, my race car! Okay, all right, there we go.
00:01:27.020 So Ted Cruz and John Kasich both dropped out, and we have to come to grips with reality now, which is to make Rails great again. Brad said he wouldn't make any PHP jokes, but I will.
00:01:42.119 Hello, hello, hello! My name is Aaron Patterson. I'm going to introduce myself because I noticed many people here are new.
00:01:52.890 In case you don’t know who I am, I go by Tenderlove on the internet. That is my name everywhere, mostly. If you like, maybe you've seen this name or my avatar, but I don't look like my avatar.
00:02:05.850 This is me—it's really me, I promise! Anyway, I'm on the Ruby core team and the Rails core team. I'm also on the Ruby security team and the Rails security team, so that's fun.
00:02:17.610 I thought I'd try this out for all the security nerds here. This is my PGP fingerprint. I'm not going to read it to you.
00:02:33.780 I am the number two Rails committer—there's the list right there. I'm number two because I took my commit points and traded them in for stuffed animals and those plastic soldiers with parachutes. I love those things.
00:02:44.730 Anyway, I work for a small startup company in San Francisco called GitHub. I recently started working there, so thank you for your patronage in using GitHub; I really appreciate it.
00:03:06.000 I like to give hugs on Friday. I'm not going to do that here with so many people, but if you come up to me later, I will give you a GitHub hug.
00:03:32.370 I started working at GitHub a little over a month ago, and I was looking through all the stuff we have, and they said, "Yeah, we've got slide templates, and they're really cool!"
00:03:39.210 So I started using the slide templates, and they are way too cool for me, so I'm going to switch to something more my style, which is just default slides.
00:03:56.220 Just in case you might not know, this was actually a sponsored talk. It is brought to you by one of my coworkers, so please tweet at her.
00:04:14.240 She said she wouldn't pay up unless I proved that was actually in my slide deck, so please tweet at her and say hello. Also, this slide deck is brought to you by my cats!
00:04:27.240 I love this face! It's the face I make when I'm staring at code. We call her SeaTac Airport Facebook.
00:04:38.550 This is Gorbachev, and he thinks he is hiding.
00:04:45.040 Here's a better picture of him, Gorbachev Puff-Puff. I have a bunch of stickers of my cats and GitHub stickers too, so if you want any, just come up and say hello.
00:04:52.680 The sock is brought to you today by my wife, so thank you wife! Now, I want to talk a little bit about my job at GitHub, or as I like to say it, "Hub legit."
00:05:37.210 I noticed something that really inspired me when I was looking through our slide templates: at the bottom it said, "GitHub: how people build software." I was very inspired by that keynote footer.
00:05:50.240 I take that statement very seriously. My job at GitHub is about developing software—bringing GitHub application development to everyone.
00:06:05.210 It means taking our development style, performance features, security features, and anything that is not core to GitHub itself—anything that's not core to our product—and trying to push it upstream into Rails or Ruby.
00:06:30.110 So essentially what my job is is Rails core development and also Ruby core development. So please buy our products and help support me.
00:06:48.199 I want to talk a little bit about my career goals. I've been thinking about my career goals for quite a while now. I'm a 35-year-old software engineer, and I don't want to admit that.
00:07:14.990 But since we're not in San Francisco, I think it's okay.
00:07:20.870 When I first started my career, I thought to myself, 'I want to get rich!' I thought about this a lot; I wanted to retire by the time I was 30 and not have to work anymore.
00:07:59.599 But then I got a little older and realized that achieving that is going to be very difficult. I started thinking, 'Why do I want to get rich? What is the point?' Ultimately, the reason I want to get rich is so I can do what I want all day—making Rails great again.
00:08:13.330 So I came up with another solution: If you're independently wealthy and can do whatever you want, then what's the difference between just drawing a salary as a cog in the machine and being rich?
00:08:30.730 So I want to be the last cog in the GitHub machine so I can work on making Rails great again. This is my actual career goal: to become a cog!
00:09:04.930 So, unfortunately, I’m giving a keynote, which means I’m failing at this job.
00:09:11.940 Let's talk a little bit about what's new in Rails 5. Rails is in its prime—this is the first time Rails has been in its prime since Rails 3.
00:09:37.600 We no longer do XML sit-ups; we do JSON burpees. Thank you, Justin!
00:09:49.720 Now, let’s talk a little bit about the new threading features in Rails 5. You may have noticed that DHH is not here; we have had a race condition, and he could not make it.
00:10:19.480 But that’s okay; I heard he's racing in LeMans, which is like NASCAR for Europe.
00:10:28.450 I know many of you did not laugh at the previous threading joke, and you're thinking to yourself, 'I came to the opening keynote for that joke?' Well, let me tell you, we have a little bit of Ruby drama today.
00:10:40.500 I’m extremely angry at Jeremy! Let me take you all back to a time—Friday, April 22, 2016, at 7:57 p.m.—to my chat history.
00:10:58.430 You see, my normal stick is essentially, you know, DHH gives his keynote, and later on I give mine.
00:11:03.080 For the beginning portion of my presentation, I usually just give him a hard time. But this year, I thought it would be really difficult because I genuinely like Jeremy, and I didn’t want to give him a hard time on stage.
00:11:22.899 Then I remembered something from years past.
00:11:28.300 Back in 2011, he did a double dream hands on stage with me. I got everybody in the Rails core team at that time to do that except for DHH, so I had to respect Jeremy.
00:11:40.029 But now he does this to me!
00:11:45.940 Five dollars! What even is this? Where did he get all these lines? Come on, he's not giving 110 percent; he's just repeating the same thing over and over again!
00:11:55.240 I feel like he got this from the surplus of slides. I'm just kidding; I love you, Jeremy! You're the best.
00:12:04.410 All right, now I want to talk a bit about some major changes in Active Record. To talk about that, I want to discuss SQL.
00:12:30.400 So I have prepared a statement; please notice my advertisement slots. Actually, we got a new thing called Application Record.
00:12:48.619 If you generate a new application today, you'll see this new class in your application.
00:12:52.200 It inherits from Active Record base, and you can put methods in that that you want to have in all of your models.
00:13:06.400 The other thing we have started doing is trying to appeal to startups. I heard in Justin's talk that we're giving way to Node.js, so that worries me.
00:13:20.370 I want to start appealing to startups—people who want to start their businesses on Rails.
00:13:36.000 If you take a look at the new application generation, you'll see a newly created file in the models directory called business.rb.
00:13:51.370 This comes with all new Rails applications, and it's a business model that helps you make tons of money.
00:14:02.580 Now, surprises are great! They're never bad, right? When you get surprised, it's always a good thing.
00:14:24.740 Last year, we had some surprises, like the Action Cable announcement, which was surprising even to me. I want to take this opportunity to announce a surprise this year that will be included in Rails 5: PHP template support!
00:14:53.700 We're appealing to startups, and I thought, "Well, maybe if we combine forces with the PHP community, we can take down Node.js!"
00:15:13.490 So here's an example. If you look under app/views, we have index.php, and we print out PHP info. If I run the Rails server and access it, you'll see our nice Rails 5 intro screen.
00:15:30.360 Then we go to the users page, and there's our PHP info! Please look around you. What do you see? It’s Rails 5 running PHP 5!
00:15:47.660 You're probably thinking, "Oh, whatever, he probably just shelled out to PHP and is printing out the thing." But that's not the case!
00:16:10.500 Let's take it a step further. Here's our PHP version; I'm going to change this to access a variable called HelloWorld. If we go back into the controller and set up HelloWorld with the time now, we'll print that out from PHP.
00:16:29.750 Then, hopefully, I’ll reload the page and see the actual time that was saved in Ruby reflected in PHP.
00:16:40.700 But we need to go further! You're thinking, "Oh, he's probably just printing that out. Who cares?" This isn't just a string, though!
00:16:56.950 I’ll show you a traditional PHP template now! Here we are accessing our Active Record models. Look at this traditional PHP template; we reload it, and of course, there was nothing there because we hadn’t put anything in our database.
00:17:23.470 So I went to the users/new page and added some users. I sped this up a little. You know, regular stuff!
00:17:40.480 We go back to the index, and there they are with my horrible HTML. I think I fixed it, but I don’t know why I needed to show you!
00:17:50.900 Yes, PHP 5 in your Rails 5—you'll have PHP templates included! I don’t think I mentioned this before, but some of the things I say might be lies.
00:18:01.660 It’s up to you to decide which ones are true and which are not. Now, let’s get down to business!
00:18:12.930 The title of my talk is what have you done for me lately? I know you're thinking, "I have done a lot for you lately!"
00:18:28.290 But I know you're all really thinking, "Yes, but what have you done for me lately?" So today, I want to talk about performance.
00:18:40.310 I love performance because it’s part of my plan to become a cog essentially. If all of your code is faster, you feel happy! It’s like Patrick Swayze from Ghost coming to help you with programming, and everything’s faster.
00:19:01.660 When I do performance work, I always keep in mind that performance involves trade-offs. You're always trading something—memory for speed.
00:19:17.190 Anyone who caches something understands this. You want a faster page, so you cache it. But that cache had to go somewhere, so you're paying some sort of price for that speed.
00:19:30.520 So let's talk boot time performance, as it has an impact on running tests and server deployment. When I do something like bundle exec rails, I consider different parts that are involved.
00:19:49.020 As soon as we hit Enter, we're spending our time in RubyGems, then Bundler, and then Rails. A lot of people say, "Well, speeding up Ruby speeds up everything!"
00:20:10.400 But just because speeding up Ruby speeds up everything, that doesn’t mean we need to write slow code.
00:20:29.030 I’m going to talk about some optimizations at the beginning of the boot process involving Ruby’s sort of, as well as RubyGems.
00:20:45.240 The other day, I ran an empty program and noted it took 100 milliseconds. I thought, "Oh my gosh, Ruby is slow!"
00:21:09.060 But if I disable RubyGems and run it again, it takes maybe 50 milliseconds! Measuring the time RubyGems takes at the start of the boot process can be tricky.
00:21:22.880 The way I do it is through measurement by elimination: look at the boot time of Ruby without RubyGems and see how much faster it is.
00:21:40.250 Now I want to point out that placing blame can be difficult when you run Ruby with a blank string. You end up thinking, "Wow, Ruby is slow!" when it's really RubyGems at fault.
00:21:58.990 So why is it slow? This file, gem_prelude.rb, is included with Ruby's source code, and it loads RubyGems every time you start up Ruby.
00:22:15.130 Initially in Ruby 1.8, you had to require RubyGems before everything else.
00:22:25.840 Today, Ruby does that for you—and that's what gem_prelude.rb comprises.
00:22:37.160 The problem is that the more gems you install, the slower require gets. If you have a lot of gems, RubyGems can slow down Ruby significantly.
00:22:55.330 We can see this using a DTrace script to watch all the stat calls and counting the number of stat calls on boot without the diggem.
00:23:05.670 The stats show that if you’ve got RubyGems loaded, you see around 298 stats on load without the "Did You Mean" gem.
00:23:18.370 If you deactivate that, we only see about 12.
00:23:25.490 Even without that gem, we see 5 file stats. This file is statting files even if they lack extensions!
00:23:37.240 Good news is the "Did You Mean" gem starts with D, and since those are sorted alphabetically, we have that going for us.
00:23:52.110 So one idea to speed up the Rails boot process is to rename Rails to AAA Rails.
00:24:06.040 By optimizing the require logic, we can start to see improvements with some various levels of memory management.
00:24:40.893 I believe the understanding of the load process can be outlined in the following, if we can see that it will save us great time down the line.
00:25:05.570 Let's talk about Ruby and Rails. We've developed something robust that continues to improve with time.
00:25:31.020 Keeping the library aware of new updates and how they may affect our processes is essential! I would love to see this started with new calls and bridge processes.
00:26:15.720 As we know, memory management is also important for optimizing the user experience.
00:26:38.879 Overall, what I am truly proud of is to see improvements shine through every time!
00:27:05.300 Remember the importance of development—the idea here is not only to create practices that are efficient but also contributions that can be advantageous.
00:27:35.470 So I want you all to take five lessons with you today: What do I value? What should I measure? How can I measure it? Does it provide shareholder value?
00:27:54.830 Let's make Rails great again! Thank you so much.
00:51:14.789 You!
Explore all talks recorded at RailsConf 2016
+102