AV-Portal 3.23.3 (4dfb8a34932102951b25870966c61d06d6b97156)

Opening Keynote by Patterson

Video in TIB AV-Portal: Opening Keynote by Patterson

Formal Metadata

Opening Keynote by Patterson
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
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.
Lecture/Conference Internetworking Personal digital assistant Multiplication sign Mathematical analysis Connected space
Point (geometry) Real number Multilateration Information security Metropolitan area network Number Fingerprint
Slide rule Default (computer science) Suite (music) Personal digital assistant Computer-assisted translation Template (C++)
Word Overhead (computing) Lecture/Conference Phase transition Computer-assisted translation Spacetime
Point (geometry) Slide rule Building Greatest element Service (economics) Multiplication sign Real number Virtual machine Online help Product (business) Template (C++) Medical imaging Latent heat Causality Different (Kate Ryan album) Information security Software developer Moment (mathematics) Bit Cartesian coordinate system Type theory Process (computing) Computer animation Software Statement (computer science) Video game Right angle
NP-hard Presentation of a group Thread (computing) State of matter Multiplication sign Real number Bit Water vapor Open set Student's t-test Mereology Computer animation Thermal radiation Representation (politics) Condition number
Slide rule
Web page Home page Group action Server (computing) Computer file Inheritance (object-oriented programming) Sequel Information Wrapper (data mining) Forcing (mathematics) Gradient Virtual machine Ultraviolet photoelectron spectroscopy Sound effect Directory service Cartesian coordinate system Mathematics Goodness of fit Integrated development environment Business model Right angle Endliche Modelltheorie Social class Row (database)
Revision control Mathematics Game controller Computer animation Multiplication sign String (computer science) Letterpress printing Instance (computer science) Template (C++)
Web page Point (geometry) Complex (psychology) Presentation of a group Concurrency (computer science) Run time (program lifecycle phase) Computer file Code Multiplication sign Real number Real-time operating system Mereology Automatic differentiation Template (C++) Wave packet Product (business) Optical disc drive Goodness of fit Latent heat Bit rate Hypermedia Semiconductor memory Software testing Endliche Modelltheorie Computer-assisted translation Metropolitan area network Task (computing) Constraint (mathematics) Electronic mailing list Planning Bit Line (geometry) Cartesian coordinate system Variable (mathematics) Subject indexing Arithmetic mean Process (computing) Spring (hydrology) Computer animation output Right angle Fiber bundle Quicksort Freeware Row (database) Asynchronous Transfer Mode Reverse engineering
Point (geometry) Slide rule Statistics Group action Computer file Multiplication sign Source code Letterpress printing Mereology Tracing (software) Wave packet Number Revision control Gaussian elimination Root Different (Kate Ryan album) Single-precision floating-point format Computer programming Extension (kinesiology) Booting Mathematical optimization Physical system Scripting language Dialect Distribution (mathematics) Structural load Sampling (statistics) Line (geometry) System call Measurement Data management Process (computing) Loop (music) Computer animation Iteration Object (grammar) Quicksort
Point (geometry) Complex (psychology) Statistics Overhead (computing) Computer file Multiplication sign Patch (Unix) Binary file Number Programmer (hardware) Goodness of fit Mathematics Computer programming Alphabet (computer science) Extension (kinesiology) Mathematical optimization Dialect Information Structural load Line (geometry) Software maintenance System call Process (computing) Computer animation Personal digital assistant
Bytecode Pairwise comparison Scaling (geometry) Computer file Code Multiplication sign Source code Translation (relic) Bit Mereology Cartesian coordinate system Benchmark Programmer (hardware) Pi Message passing Process (computing) Computer animation Speicherbereinigung Normal (geometry) Booting Compilation album
Polymorphism (materials science) NP-hard Complex (psychology) Run time (program lifecycle phase) Code Multiplication sign Function (mathematics) Mereology Semiconductor memory Different (Kate Ryan album) File system Social class Scripting language Structural load Bit Instance (computer science) Type theory Process (computing) Computer science output Website Right angle Pattern language Bytecode Point (geometry) Slide rule Computer file Patch (Unix) Online help Streaming media Rule of inference Number 2 (number) Natural number Software testing Computer-assisted translation Booting Compilation album Mathematical optimization Multiplication Graph (mathematics) Validity (statistics) Key (cryptography) Content (media) Counting Cartesian coordinate system System call Cache (computing) Computer animation Logic Network topology Object (grammar) Table (information)
Web page Point (geometry) Complex (psychology) Run time (program lifecycle phase) Code Multiplication sign Patch (Unix) 1 (number) Gene cluster Virtual machine Coprocessor Event horizon 2 (number) Goodness of fit Computer cluster Semiconductor memory Operating system Speicherbereinigung Diagram Mathematical optimization Metropolitan area network Social class Physical system Information Key (cryptography) Block (periodic table) Data storage device Shared memory Bit Median Instance (computer science) Cartesian coordinate system Benchmark Substitute good Uniform resource locator Arithmetic mean Process (computing) Computer animation Personal digital assistant Right angle Object (grammar) Quicksort Routing Speicheradresse Library (computing)
Web page Process (computing) Computer animation Inheritance (object-oriented programming) Semiconductor memory Operating system Right angle Object (grammar) Freeware Physical system
Web page Area Default (computer science) Server (computing) Presentation of a group Copula (linguistics) Code Sheaf (mathematics) 1 (number) Product (business) Web 2.0 Process (computing) Computer animation Operating system Object (grammar) Resource allocation
Logical constant Complex (psychology) Presentation of a group Dot product Strategy game Semiconductor memory Water vapor Object (grammar) Mereology Social class
Web page Dot product Computer animation Multiplication sign Internet service provider Green's function Memory management Speicherbereinigung Object (grammar) Measurement Metropolitan area network
that the the the the and the but our 1st er morning q this morning in that is Aaron Patterson connected alive if it it uh if you the and in once again do this real quick for posterior thank you thank you no I'll give you a hug but only in person the the no OK but at time for me to turn into a nervous wreck so that the Chester dropping of bombs analysis is if if if it had to do on my cover but thank you however Merry go it so dead crews junkies in both dropped out so we we have to come to grips with reality now which is to make thrills greater it that Brad said he would make any jokes but I will say that that OK i i hello hello hello my name is Aaron Patterson I'm going to introduce myself to the notice many people here a new so in case you don't know why and my name is Eric Patterson I go by a tender love on the internet that is my name everywhere but mostly and um if you like maybe you've seen this name or my Avatara I don't look like my habits are this is that is needed
it that's actually me it's really promise of anyway I'm on the very core team
and the rails toward the end I'm also on their review security man the real security team so that's that's fun of that if I thought I'd try this out for all of these security nerds here this is my PDP fingerprint I'm not going to read it to you here I am the number 2 number 2 rails committer that's there is the listed
there and number 2 there is no number 2 is because I took my commit points and I traded them in for and stuff animals and those those later use plastic soldiers with the with the plastic parachutes all of those things but anyway I worked for I work for a small start-up company that is in San Francisco Call did have
a I recently I recently started working for those companies so uh thank you for your patronage using get over really appreciate it and the company the company because it is very would it that it I had but anyway so so I would like to give hugs on Friday I'm not gonna do that here with so many people but if you come up to me later I will give you a get hug his it that the anyway so I started I started working again hub-like of a little over a month ago and I was looking through all the stuff we have no idea how we've got the slide templates and they're really cool so I started using slide templates and they are very cool the way too cool for me so I I'm going to switch to something more my style which is just default slides so
I have just in case like you might you might not know this for this is actually a sponsored by a half but it is brought to you by 1 of my coworkers and I have no t please suite at her because she's paying me for the slot emoji and she said she wouldn't pay up unless I prove that was actually my slide back so I want you to low and this is also brought to you this this slide deck brought to you by my cats through this is in
is I love the space just it's like this is the phase make when staring at currently have a pet at at at is this is this is SeaTac airport face but due to what we call a two-tier 1st overheads and that's the that's a resting
phase and this is garbage he thinks
the inviting it it is a better picture
Gorbachev puff of the words and then I have I have about sticker the my cat so if
you also have given stickers to so if you want come up and say hello to me I'll give you thicker than my cats and didn't stickers if you'd like them all the stock is brought to you today by my wife so thank you
I this the but I think he is this so I wanna talk a little bit about my
job and get out of bird I you like the way I like to see a jet of it and with it is anyway I get out I notice so 1 thing that really really inspired me is when I was reading this I was looking through the slide templates and I noticed that the bottom said get help help people build softeners very inspired by that but you know footer but it has hit but anyway so I I actually take that I take that statement very seriously and that that is what I am doing again have like we we develop software you all develop software so what my job is again Abbas basically bringing did have application development everyone and that means taking things like our development style uh anything we use for you know performance features security features anything that is not core to get have itself or anything it's not corner product I'm trying to take that push upstream into rails were Ruby any of those any of those types of things trying to make them public so we can all benefit from them and build all this can build their applications so essentially 0 my job is to do is to do real score development and also recorded moment so please fire products of support me it had so I wanna talk a little bit about my career bowls of the other thing about my career goal for quite a while now and I am a 35 old software engineer and I don't want to admit that but we're not in service specific it's OK so yes this is this so I when I 1st started my career I thought to myself you know I wanna get rich thought about this like I wanna get rich I'm going to retire by the time I'm 30 I will have the work anymore and then I go a little bit older realize that you know it's going to be very difficult and I started thinking OK why do I wanna get rich like what is the point while you actually do this and the reason I after much introspection the reason I want to get richer so I could do what I want to do all day which is making rails great again so I came up with another solution for this is that there is a different solution so think about this so if you're if you're completely independently wealthy and you can do whatever you wanted to do all day and we wanted to do was make rails great again of lower the difference between just drawing a salary on that like being a cog in the machine versus being totally rich so I I what I want to do is my career is I want to become a cause I want to be a lost cause k in the image at time of the year so that I can work on making rail so this is my this is actually my career goal is to become a cog so unfortunately I'm I'm giving a keynote so you can tell I'm failing at the start of that that of career not going so well what anyway I let's talk a little bit about what's new in real life right so new like of 1st off of the rails and prime this is the 1st time the
rails has been trying since Rails the radiation is we can no longer do XML students duties on Berkeley's thank you just think of that I wanna talk a little bit about what have little bit about threatening threading features in real side you may have noticed unfortunately that idea teachers not here we have had a race condition he could not make and now that but I guess that's OK his racing woman's that I heard that that is essentially this nascar for Europe so that that that that that I I know many of you did not laugh at the previous the previous threading joke and you're you're thinking to yourself I came to the opening keynote and I heard that joke there well let me tell you we have a little bit of Ruby drama today I'm extremely angry at Jericho he did I I want to take you all back to a time back to a time of previous plays back to friday april 22nd 2016 at 7 50 70 I'm going to take you to my chat history that I right there on now I see it if if it if you see my normal state is essentially to you know do you take his his keynote and then later on I give for the beginning part portion representation I basically just give him a hard time and I thought to myself this is going to be really difficult this year because well I really like Jeremy I do wanna give my hard time on stage so I was trying to figure out what made you with the opening part of my presentation and then this that it seems that even back so this is what is
2011 5 years ago he did it he did the double during have on stage with me I got everybody the rails caught him at the time to do that except for DHH so I had to give Jeremy water respect but then he does this mean right so I'm going to give a little bit more of our time 5
and I thought
that the 5 dollars and
it it is a 5
dollar foot but if I get back at 1 even if the learning and always
lies commodities he's not giving 110 % is repeating the same thing over and over again I feel like he got this from the surplus few slides if I just getting I love you I love
you dear me the best at our I so I wanna talk a little talk about some major changes in Active Record and talk about some major changes of so to talk about this I want to I wanna talk about sequel of a one-time SQL also prepared statement in we've noticed my advertising slots so I actually actually got a new thing called application record of it if you generate a new application today you'll see that we have this new class application wrapper record in your in your new application it basically inherits from ActiveRecordBase and you can put methods in that you wanna have an all your all your models of the other thing that we started doing is like I want appeal the start ups I heard that I heard and just stop that we're giving way to node j ust so that like worries me so I wanna start I wanna start appealing to starts people who want start their businesses on rails so what we've done is let you take a look at the new application generation so here I am I and they carry it's fine I'm generating new application of i've names this application on yellow what to and that is because I have multiple and yellow what applications on my machine effect the you'll see here there's a new file which you care read but it's OK communities you here and if you look at it we have under the models directory of business lobby and this comes with all new rails applications if you open this up it's actually a business model for you so this is how you can make tons of money so we have that we generate a new business model and this is actually happening complied business model so you go the so I I love surprises surprises are great I mean they're never back right when you get surprise it always always always a good thing right so you go home and there's a surprise party for years super happy that they never turn out to be terrible things and and last year we had some surprises like we had a surprise this action cable announcement is a brand new surprising thing to even me I still I want to take the opportunity this year also announced surprises is going to be an rails 5 and that is huge the temple support i in I figure I fear the solar appealing were appealing to start ups of in I think well maybe if we combine forces of the PET community we could take out take out no JS so what I've done today I
want I wanna give you an example here this is if you look at a at years we have index PAGE and we opened up huge he info and if I run the rail server and then access access that you'll see OK here's a nice are nice so rails 5 in 1st grade and we go to the user's page and there's RPG info I I want you to look around you what do you see rails 5 running THE 5 fish
that had so this is of like 0 whatever you probably shelled out to PhD in his printing out the thing and so this is no big deal well let's go a little step
further so here's our version the I'm change this to access some variable Hello world you'll see that that hello world that and if you go into the controller 1 workers them you can do it by you'll see we have an instance variable named whole world with the time now and we print that out from th the and then hopefully go over here and reload the page and you'll see the
actual time that was made in Ruby and goes into your future templates this is not a joke and but we need to go further this is enough you're thinking of you probably just printing out it's just a String who cares about that this is burden that out and sending it you know showing up to the it's the it's doing some magic for no no no no no
so already there's were axis are active Record models here I'm going to go in and access users all Daria that instance variable and then to my horrible horrible page you can see here the traditional PT template is you'll find in most PHP files including my terribly broken HTML look at that look at the indentation good job so we reload and of course there's nothing there because we input anything in a database or go over to the users new and ads and users I think most the supple just adding uses its normal you know normal stuff
so and news and then we go back to the index and there they are with my horrible HTML and then I think I fixed on why need to show you this just I was like I can give my lists rates 50 added traditional indentation narrative with the bad while the so yes he 85 5 in your Rails 5 will have huge he templates I I don't think I mentioned this at the beginning of my talk with some of the things I am I a m saying to you might be a alive so it is up to you to decide which is true in which is not at odds so let's let's get down to business of the actual title talk we're we're we're done with the the fun part of the presentation get down to business so I do I typically do the reverse the reverse mode style presentation where we have fun in the front and then business in the back so let's get down to business the title of my talk is what have you done for me lately I and I know you thinking to you know I I have done a lot of stuff for you lately I really have but I know that you're all thinking to yourself yes but would have be done from you wait a week so that's the that's the real title of my talk will be done for me we really lately so today I want talk about performance surprise performance and so and talk about performance I love performance I love faster and the reason I love it is because it's part of my plan to become a college essentially if all your code gets faster you feel happy right it's like I'm I and you know Patrick Swayze from ghosts coming over and helping you helping you do programming you like how everything's faster feels good I'm not sure what's going on you look over his shoulder and nobody's there right so at the media I wanna be that hard it so our and talk about the time performance runtime performance and memory efficiency I and what I do a lot what I do performance work I always have to think that performances it's always about tradeoffs mu during performance work it's always about trade after training you always reading something whether it's memory for speed or you know anyone who cashes something understands this new 1 have faster page you catch catch the page but that cat had to go somewhere to paying some sort of a price for that speed or maybe concurrency for memory this was an interesting 1 isn't so common um you give up concurrency so you can save memory or complexity for memory like maybe you maybe you want to reduce the amount of memory that using so you increase the complexity the code and I'll look at some of that later but the point here is that performance is never free it's never free you can't you can't just have free performance so it's very important for you when doing performance worked understand understand the constraints working on how fast the code have to be how much memory should consume all these particular constraints you need to figure out the most before you do any performance work so I'm going to talk about real time performance and I think this is interesting because I reading I added over of specific at it is that I think is interesting because the impact running tests I impact server employment restarting production I like restarting self that is happy for me I'm not I'm not a real spring user so good time performance is important for me when I when I look at that basically I I think about boot-time performance from the very beginning when I do bundle exec rails like this is it this is it I look at this whole thing and I think about the different parts that are involved here so if you look at you look at each part of this command the very beginning we have the bundle commanded that bundle man has actually been style this been stub is installed in controlled by ruby gem so if you care about the speed of just that bundle part you need to look at Ruby gems if you care about the speed of the exact part the exact part of this command you probably have to look at bomb was you know if you care about the speed of that exact part that is where you need to look with the rails command you need to look at rails and also with the best man you need to look at rails as well now if you think about the book process and we extend those lines out a little bit it's essentially a timeline of what your code is where code is doing at any particular point in time so we can extend that out we know that as soon as we hit enter essentially we're going to spend your time in Ruby gems then Bundler then rails that's where that's the timeline of Abu process and a lot of people say OK well what you know speeding up Ruby speeds up everything want to speed up Ruby rather than speeding up you know speeding up those particular things that I do like working on speeding up Ruby I think it's a fun task but just because speeding up Ruby speeds up everything that doesn't mean we need to write slowcoach we can write faster code and have speed today so I'm going to talk about
2 optimizations at the very beginning of the process is not about Ruby sort of animal talk about regions as well so the other day I was running on empty program I do readers to be an do blanks training and I see that it takes 100 ms I think to myself on Ruby is slow and anybody that runs it runs Ruby in this program and see that it takes 100 ms they say it so I can't blame them for saying that like everybody should think this is slow but if I disable Ruby gems and again I see that it takes maybe 50 ms now I wanna make 2 points 2 points of the slide 1st is that of measuring measuring the amount of time that regions takes is at the very beginning of group processes fairly difficult things away reduces measurement by elimination essentially all what I do is say OK well let's just look at the blue time of Ruby and then remove Ruby gems look at the difference between those 2 and that's how we can kind of gage what how much time we're spending in regions so we can we know that we have to optimize in that particular place the other point that I wanna make is that placing blame is difficult when you're writing that Ruby dash the blanks training How do you know like how do you know that it's actually regions of fault I I I would not blame anybody for looking at that and saying wow review slow right you it even though you don't know under the hood half that time is spent in regions not actually result so why is it slow but let's look at the reason slow is this this file Jim prelude this the file is in our rubies source code itself if you go look a resource followed you find a file called GEM prelude Derby when you stole Ruby you won't see this file anywhere but it's only part of source I distribution so if we look at the look at the inside of this file file loaded every time you start up every time you start of Ruby so the 1st thing it does is it loads RubyGems right here so wire we loading regions why does this thing load regions at the very beginning of the process and the reason is because back in the 1 8 the bad old days of 1 8 he had a require before everything today Ruby 1 9 plus you don't have to do that anymore it's built in ruby does this for us and that's what the gem prelude provides to us so we will ever be gems and they'll say here this line loads the did you mean John this is new in Ruby 2 . 3 so what is the did you mean gem do I it gives you it's if you make a that tries to suggest you what it should be so here I've made a typo I wrote object IP and then it says to me are did you mean object ID so tries to suggest the correct method for you this is essentially the click the for Ruby and if so did you mean is again did you need is a jam and is shipped with Ruby as a gem which means that gems has loaded religions is responsible for doing that so right here did you mean I regions require loads of digiMine John so what exactly does requirement to do this is essentially a TLD DR of the requirement that any during its super closely but essentially what RubyGems require method does is the iterates over every German on your system says page and do you have this file if you have this file I will activate you and then try requiring file so that essentially this loop right here that loop is 0 3 and or just all and what this means is that actually testing for 3 particular files and saying hey you have the file of the past required the other file with B. extension or the of the file of SO extension so what this means is that the more gems you have installed the slower require gets and you'll notice that we always do require the beginning of the review bu boot process so what this means is that the more gems you have installed the slower Ruby gets the we can actually see this in action so the D trace script watch all stats step calls for a particular process what this what this command is doing is running as root I have to be rude to run at a desk you did make it not print out stuff don't care about here I wanna look at all stack calls on my system and they here a print out the files that's being stated and then down here is the command and actually running I use R be inferred from my Ruby management and you'll have to figure out a different command for yours and then just running the empty program there so when I run this we can watch this in in action you'll see mean if I run this just count the number of that calls with 3 on my system we see about 298 stats just on of without the did you mean if I deactivated did you mean jam are we only see 12 and without regions or the digiMine you mean gem we see 5 file steps and what's neat is if you look at all these all these stats you'll see a print out the looks of like this a sample this is the whole 300 of them a so this is just a sample of them and what you'll see is that it's trying to go through every single version of every single genome that's on your system looking for that file but by the just a side note I think this is really interesting
it's standing files that don't have an extension and Ruby will actually work if that file exists it will actually require so I'll that it's again have some good news
is good news everybody good news the did you mean John starts with D D is pretty
early in the alphabet and these are sorted alphabetically so only go to the use it that at this so we got that going for us so 1 good way of 1 good way that our proposal we speed up the rails due process is that we rename rails to a a rail slot this is this 1st His provides the phone book that are so the let's make improvement we can improve this I and will get actually speed this up by using the gem command the gem method and so on the the very top that top programmers as a normal require requiring the digiMine gem of the next 1 is the same in a different program that does gender mean and then requires if we compare the stats on those you'll see a bear required to about 3 100 Stat calls were doing jam + require only took 16 so why is this faster the reason it's faster is because if you look at that John thing which I know you can read it it's fine the gem command actually mutates load path and the 1st thing that required does is ask Ruby hates can you require this file is this file in the load path and if it is in the load path it'll just require continue on with our lives so we have an o 1 0 1 look up of the gene's that we just looked we know the name the gene's fact we just look it up and we have an o 1 hour require the file is not actually a 1 is just a small so to fix this we just patch the gem prelude in this the patch applied to the gym prelude Justin to align differ went from bear require of all went ejemplos require of 0 1 so in this particular case we're trading off complexity for speed OK where adding more complexity the code but we're gaining speed of this now complexity does have over and i in even this even this patch has overhead and you might be thinking hey that's only 1 line it's 1 line it doesn't matter like yell at that that's no there's no no cost that but if you look at these commands you'll see what's I wanna go back to this command of there is an optimization regions when you do Solbourne learn it installs the bomb the bin file of regions knows that hate when you run the ball a been file we probably want to activate the bomber agenda it came from the biology and we know that a k it came from the bomber gentled activate the bomber down as soon as you call a bundle of and here you can see this in before regions to 5 to if you looked at those been stubs you'd see right here we have those 2 1 slowed djembe on learned than do the do the load this for all themselves I'm not I'm only taking on Butler cause a disease all time and it's great and anyway so we have an no 1 require here so this this is what it is and then if you look in regions 2 5 2 2 2 6 2 that that GM calls actually gone so we've gone to an O N O and time here which means all of your been solved now take now gets lower as you install more so the point here is that even though that was a one-line change even regions maintainers can Mrs. to occur so you do have to think about these trade-offs when you're looking at co complexity alright right so let's move on but we did regions and now I want to talk about rails I I don't have my Rubino Ruby so much was about up rails I want I'm excited talk about this because of new technology that is not actually knew because I want to quit in fact yesterday and you just told you all of those this so if we take a look at start up times they'll break down something like this the natural times you might share here these these numbers are all whole so I swear on stage these numbers are all posted in the I I think that's where where a p r is that these numbers than just leave it is made up of what I'm trying to say here is that these are not actual time this thing that you do is you bring your putting a rails process and they take some amount of time and we don't know what those times are we don't know what they are so how can we measure in 1 way I do is I use GC that's that's like the information about the GC or
sometimes I'll just I'll just disable the garbage collector and compare and compare the benchmarks to see what happens so we can eliminate GC from the GC from the boot time process we can measure it in fact just by doing the simple things so we can cut that out if if we cut that we see doesn't doesn't really impact time so much so we can only that we have another thing another thing in our pi high which is searching and searching the world pass for files and again how we actually have we have code for caching these look up so we don't we don't actually do load past searches when we blew our Rails application of it but you you can also do this as well if you get this gem of a cold boot scale and you can you can also catch these look up so you have to do with passages on your on your at boot time for your application so that we can eliminate that from the pies well on a and like I said we will AGC earlier so basically all really left with his compilation and execution execution so the amount of time it takes to compile your code and then whatever execution were due to doing a the time so let's tackle compilation and to learn about this I want you all to go to stock which was yesterday and so i'm gonna talk a little bit about it now with your normal programme full tool a little bit so that this we take source code we compile the source code and byte code and then we execute the byte code so the idea is is we want take that beginning part that source code the bytecode translation cash that in a file somewhere so that rather than doing rather than doing this translation the time instead will do something like
this where we read the byte code from a file and just just evaluate that codes we don't have that we actually have to do the compilation step anymore we can cut that out of the process so here's an example of a
compilation script this is some of these methods a new in Ruby 2 . 3 so all this does is taken input file and compiled to an output file it we can run it and you'll see like when you run this compile below that are being you'll see there's some just some binary data in there so our 1st half is done we use completed our 1st after the next part is we need to be a load and execute this byte code so this is an example of loading it you'll see we load that bytecode evaluate the byte code and then we assume that the hello class exists and we knew that existed in that byte code so this this works so we know that hellos available if we run it works so we were able of the bike real the right to this and what back and so the 2nd half is done we are 100 per cent on the rails and fast and this is because I always give 110 per cent so the that integrate was require we need to integrate with require and this is something that I really wanna do what we have to do it to get out get over this 10 % process so let's look at the look at the year require process we have 3 different files a and C and they depend on each other and if we look at the dependency graph looks something like this we have 80 which depend requires B B requires CC goes back to be so we have this kind of weird dependency tree if you look at the actual of the logic of the choir process essentially be will will start to require B I will acquire lock for B will start to acquire lock for c try to use the a b is already blocked so we can use that we finish requiring CD release lock procedurally slot for B et cetera et cetera so this sucks up the point here and they with this slide is that there are too
many rules and I do want to figure them out so essentially what is patched through be such that you would call call back when you need to look up a file and we could just have a do whatever we want to do at that point so we essentially have a look up here our require of hope here that would say OK when we when we Walid through instead of looking to the file system for we would actually hit this hit this method and we can do whatever we want to with it and you can go look at that on my eye on my for preferably again obvious gotta get that money is so we have an example here the loads compiled code this is lazy compiler give of that that so if we compare the 2 if we boot boot rails with and without compiled code we see this example so before before it took about 1 . 8 seconds after it took over at 12 swore about 30 per cent faster and so I'm I'm actually really excited about 30 % faster collegiate said in his thought all it's not that much faster it's only 30 % faster who went now is 30 per cent that's very interesting better than what we have today we should we should do this is what I think is really cool about this is the more code that we have to load the bigger impact that the snake and on are application work we have a lot of code so this will help us out a lot so for future work I looked up stream is new called active I can someday I I think would be interesting if we compiled code on Jan installed so we could have that available as soon as we installed genome and the other hard problem of computer science catching validation so I'm not sure about that you to figure that out so natural look at runtime performance of I talked a bit about boot-time performance now wanna look at runtime performance I wrote a patch while ago for doing a polymorphic in-line caching and I wanna talk a little bit about this so what is in-line caching of cash there's a cash in your code and you don't really see it this cash lives anywhere there's a dot so where that cash is right there and it says hey this object is of type a low where is the through method we have to look up the through method when this code is executing and you don't see this cash because this catches in mind hands in in mind can yeah it that is so basically this cash as soon as that assumes that code executes the cache contents will look something like this table where we have a key which is our how low the class and the method name and the value of that cash would be the wear that method is located so the 2nd time this executes because the the answers they all I know is hello and I know it's a method through the cache I can just go look at that go directly to that method so our next thing in-line caching if we have 2 types here this it it seems that 1st Tiepolo we get in this but a popular the catch the 2nd the 2nd variable that comes through for type world and that's different we a cache miss the the key is wrong so it misses and what this means is in Amariah capsizes 1 we can only catch 1 1 value and we call was a monomorphic in inline cash at 1 value 1 type stored in this cat so what if we had a cache size of 2 if we had a cache size of 2 then we can say OK we missed on the first one we missed on how low the bag it's put into the cash we missed on world but back and put into the cache as well but the subsequent holo hits and the subsequent world hits as well so a cache size of 2 or more we can call that a polymorphic in-line caching caching multiple types so this particular optimization pays off when these call sites in multiple types if you see many many different classes at that particular call sigh it pays off so we pay often we see multiple types and you can go see I I have this polymorphic in 1 cache implemented again on get have a go there so you can check it out and then tried out yourself but unfortunately the till the hour is didn't help us we we rented our application in and out of it didn't it didn't help our application at all and the reason is because if you look count the number of types that you see in the application is the test application that I use of if we count the number of types only 3 % of the call sites had 2 or more types which meant that we would only see maybe possibly a 3 cent performance improvement so this particular optimization is a trade off of complexity and memory for speed where adding more were using more memory were adding more complexity in were gaining were gaining speed with this but unfortunately that speed is only 3 per cent so it's probably not worth it so this pattern for our application this that was not worth that so this probably won't get upstream the interesting thing we found was a we refiner calls said that had 16 hundred types 16 different types of objects pass through 1 method and I thought that was very interesting where that actually came from someone calling instanc valid on object when every call instance evil on something it creates an anonymous subclass of how low the anonymous
subclass of whatever it is it attaches that you probably knows as a metaclass now that means that in this particular case is through method right here an object of are always sees an anonymous class which means this is always a catch next so when I was counting these are application that's roceedings anonymous classes coming through 16 hundred anonymous classes so but it's an interesting thing an interesting question asked like what what classes this when you look at VA what classes of R and you think 0 well it's an instance of how low but actually to think of this more as an instance of alien anonymous subclass of hello and that anonymous subclasses lazily populated it's also known as the medical metaclasses actually OK because of the whisker of substitution principle it's fine the VM optimization we go around pretending that this is how well most of the time so when does this when does a singleton class gets instantiated anatomical instanc valor singleton class or of death add a singleton method to something there that there's other cases where this happens with these are like the main ones that I saw that know you're wondering given I'm rails that presented with this info then why should I care if so uh well the the reneging cares as some libraries through this and unfortunately they're popular libraries like our spec or event machine of so the solution is it don't write code like that just on don't do that please and if you really really think you have to I don't seriously it is built of but if you really really really really must do that we we can speed up and what I found interesting and ah aspect is that these these singleton classes the singleton classes are classes with no new methods added to the median at any methods the singleton class of it is used the singleton classes a storage locations so a singleton class with no methods is exactly the same as its superclass meaning that it those 2 things can share cash key so what I did was I added a patch to add a patch to Ruby that would that well have upstream this but I made a pact for Ruby that would act which catch sort looks like again due to uh this is this is here's a benchmark for this is a benchmark for comparing um essentially polymorphic all sides between the singleton class in the non the non singleton clusters and if we look at the original speed is it took about 2 . 5 seconds from spends work after sharing this catch he's we see it go down to 1 . 3 seconds so it's about 45 per cent faster in this case were trading on trading complexity for speed so in this case it's probably worth while that's a good that's a good performance improvement we saw good spirit speed improvement the patch is relatively small innocuous another thing I thought was interesting about during this work is that I I felt really really bad about it because I went I subscribe to the just don't do this of school of performance improvements I try to refactor are expected not using 10 classes anymore it turned out it is actually easier for me to just optimise Ruby so I don't like I don't mean that as a digger or spectra or specter gray under saying tacos man alright so memory efficiency Atlas soccer let's we we've done good time we've done runtime let's memory now I wanna talk about copy-on-write a cow and we use a copyright a lot you probably use that so 1st I wanna talk about impacts the copyright I wanna talk about he play optimizations so these are the 2 topics were discussed here and the copy-on-write optimizations essentially what that is is when you have a pair care process that pair process points at some memories that pair process gonna for command to children and those children don't get a copy of that memory the actually just point at the at the pair processes memories the shared this share that memory when you have 10 processes it doesn't use 10 times memory it maybe uses only that pair processors memory they all point that 1 particular bit now if any of these children rights to that bit of memory the pair process should see that right happens so the operating system does is it actually copies that memory down to the child process so that's why we call copy-on-write when you write to particular memory location the operating system copies for us so that when that copy occurs that's what's called a page fault so there is a page fault that occur copyright page fault that page gets copied on those faults so the operating system copies some of the memory to copy it doesn't copy that entire block like my diagram should actually only copies the bits of the copies in a location where you wrote but it copies in page size blocks operating system page size blocks so if we look at Ruby's memory layout rubies memory layout
looks like something a bit like this where Ruby will allocate a page and then all of our route all of Ruby objects are allocated inside that page so as we allocate Ruby objects those ruby objects will fill out fill out those pages and if we need a new page review will allocate 1 a whole new page and then we start allocating objects inside of that now when GC happens if the page freed the garbage collector well will free up any object we have these objects that give freed in here and if you look at this it looks a little bit you can think of this as some a little bit like Swiss cheese it has holes in it so there's these little slots that have free free objects and if any pages are free the garbage collector will actually remove that remove that page now what would be cool is if these 2 objects here then moved over to the other page then would have a free page here and we could free that pages well I'll be really nice unfortunately In arise garbage collector
objects don't move today they don't move so we end up we end up with a heat that looks something
like this so we have a bunch of free slots Swiss cheese I like to call Swiss cheese is just got a bunch of holes now this actually waste memory in 2 ways the 1st way is we have a copy copy-on-write wastefulness so the parent is pointing in these particular pages then we fork the child is also pointing at the same memory layout know the child allocates an object in a goes there and we have to we get a page fault in the operating system rights and operating system size page to the child process but that operating systems size page is larger than a Ruby object which means that were actually and copy multiple things from the parent process to the child process so on Linux
and OS 10 the default page size the operating system page sizes for k a Ruby page size that block I was showing you 16 K the Ruby object is about 40 bytes so 1 Ruby pages about 400 objects of 1 Ruby pages for West pages and 1 always pages about 100 Ruby objects so there's any free slots inside of any of that 100 object area were actually copulas for the child so the answers were probably copying too many objects so this only impacts ruby ruby code the 4 works so what forks and Unicorn for we use unicorn in production probably many of you use this most MRI web servers for so what I was thinking is this this section of my presentation has that kind of unfortunately adjustment thinking about it because it's fun to think about but if we look at it if we look at a
page sideways and allocation move something like this were going laughter I allocating new new objects right for filling up that page will be interesting is if we could predict which objects were going to be old you know what if we knew that these particular object republican the old and the other ones we don't know about me they'll be old maybe they'll be new we don't know but there's some objects we might know world so if we know that those are all why we start may be on 1 side of the page with the known old objects and the new side page with the other side of the page with possibly new objects that way we would end up with a page where 1 side of looks like Swiss cheese in the other side looks more like good so we have a we have a more solid page and those probably old objects will be copied to the child process or maybe we could even have pages
interest strictly dedicated to things that are probably old objects so you might be thinking water probably old objects and there's actually a lot spots that we can see these for example when you create a new class you know that class is probably not going to get garbage collected in Ruby are classes are objects that class probably isn't going anywhere near there is a module neither is a constant there's other things to that we can say like maybe these you know these things are probably going to get all so trade-offs What are the tradeoffs for this unfortunately I don't know yet because I haven't implemented nobody's implemented it yet but my current strategy is basically wait for which had to do it and then go to his presentation and when they do so maybe it's complexity for memory how complex it is that I don't know how much memory is to take we need more tools for introspection I think so I built a tool that I thought was really fun I he fragments is it and what it
does is shows you lay out the fragmentation layout of your memory uh this is the starting OK so on the left side there you see the way out of the memory the black parts are a free slots those are where we can allocate objects the red dots those are
all the objects in green dots are a new object so you'll see as allocating objects in i b it's filling out that page you you can see as soon as it does a garbage collection it's actually wiping those those of away from a disable the garbage collector and allocate a bunch of stuff we can actually see the see that heap expand so it gets wider and wider and then when we garbage collectors they all go away
go Aaron yeah reduce the amount of times alright I will sometimes in the rapid
up and wanna wrap it up with 5 lessons the what do I value what's I measure How can I measure and does it provide shareholder value 5 lessons when we repeated what I value Watson measure how can I measure it and does it provide shareholder value has all right everybody let's make rails gradient thank you so much this much my man might face