Bestand wählen

Ruby Debugger Internals

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Erkannte Entitäten
i would in the world in the hello
everyone I have my name is Dennis shook off and Ieave leaving sink is broke pressure and I have basically that's awesome
because in the summertime as Saint-petersburg looks like this but I should warn you if you want to go about this in Pittsburgh in any other season uh you probably would be disappointed because it looks like this the so I'm
working jet brains for 6 years and I do lots of different stuff and I 1 of thinks a who is working on debugging support for so I decided that would be a good opportunity to tell you about the things I know of the binding API and then dividing journals so that if you want to do a
debugger but you need to be able to answer that do basic questions about the 1st 1 is where we are so In order to have debugger to heat your breakpoint or provided some information it should know are where in the code its position like the file and the line and the 2nd question is what's going on in we need to know whether would have an exception raised and what I variable values that we have and stuff like that so hot that may start with super small
demo so that here's a really really small program and a that's how would look the most simple scenario of debugging we put a breakpoint on some but then we executive program and stops on that line and we can see a variable values we can see the global variables so we can see the stack frames Our and you
can switch between a basic frames and and also began in Eliot's
different the different expressions so that was the
the to the questions but there's also 1 very very important side question that's the
speed because the than 1 divided to be super slow we wanted to be I expressed as possible and ideally as fast as the program without the bug so during the talk I'm going to
be doing some measurements and I'll take atomic malls really simple problem 0 and with that lots of iterations and uh in order to avoid input output of if effects but I will be I would do you know I was put in that program and I am going to be measuring the the locution using the default of be benchmark framework so here is our really simple a small program lots of iterations up to 0 set the benchmarking I'll need to write without any any debugging API enabled and on my machine it takes about that 5 seconds that better so how are we going to understand where we are at the moment really by 0
1 No . 0 introduces really simple and handy function its call citrus fine so it takes a Proc and that every time an event happens over and rubidium in happens so you hold your block gets cold and you get I didn't file line AB binding and costing of file line up pretty of this idea is the method name that's currently executed our class name is the class of the object of which is that modus executed and let's take a look at a deeper look at the 2 other arguments how are the first one is events
and there are 7 groups of different events are the most basic and the most people often have being event is lighter and it gets cold on every line on almost every line of your code and sometimes it gets cold twice for line but usually like 1 line 1 line of 2nd rupees call and return that these 2 articles that generated when the museum calls and method or the transfer from a method 0 I see call and suture these are basically the same except they are generated when you are in given us a function of glass and and are generated when I really be and starts interpreting the clause body and and when the covariance on a rise abundance generated when the exception happens and Ruby 2 . 0 0 0 generates our 2 additional classes like the the be returning which are generated when the execution enters the book or leads the block and that begin tried and when I me a start or end of the track all I should notice that these trees find doesn't know about these 2 new classes so the other interesting parameter is binding but basically that's the same you would get with the kernel biting buying and nite captures the execution context such as variables methods and there will use so you can use that to perform evaluations later on the so let's say it's some money output to see how far program
looks from my abiding point of view so we see that on the 1st of all we call method our action on an object than the than alignment event is generated for that 1 methods on and we have mercy call as we are entering times methods are you may notice that that's a sequel because that's the core method and it's implemented in C then we get lighter than for i times book then we get cold and for our goal Terrell's Conf method line for that method and are basically we are returning from from all of those so does anybody have an idea how long will it take it yeah definitely it takes about 2
minutes like dimming is from a 5 seconds was what's what's going on but basically the problem is with
the buying are evaluating binding is really really expensive so to
evaluate the binding we need to what was stacked to gather all the available variables we need to store related there will use and that it takes lots of time so what should we do like we can just
keep common with for the health the but to be honest I have launched the I was able to do both these simple Rails application of the the set trounced trace find enabled once I haven't tried that fit in with anymore so what should be the and the Ruby 1 . 8
. 3 introduces a new matter it's called R. B. and the man who you may notice that the code below is doesn't look like really because that's the yes the and then that thank you can specify the function is basically call that would be called and 1 big difference is that you can also specify events so for example if you don't need a line event you can just specify that you want all other events and that would make execution tested so let's try executing of the same program with the empty call that and but you know all the answers and it takes 10 and a half seconds met so generally haven't API there should
be at rapid down that you can use unfortunately that's not the case of there is a gem but it's only compatible with the I'm really 1 . 8 so I better at some point I thought OK I'll just do some stuff and the thinks the odds compatibility and get it ready for 129 and do and that well but actually quite a laser person
I really love being lazy and then some thanks to cliche I can do lazy because he did all that for Ruby 2 . 0
and that he brought us you API that's called tracepoint at the but inspectors so what's the tracepoint basically that's the wrapper around the end a it and folk we their good object-oriented Ruby API so what you need to do is just don't specify events you want to listen for and you'll get your book called every time that that happens and then you can get from from the betrays . object you can get all the information as you can get from this a trace file let's try program with the tracepoint so it takes about 30 seconds which is not as good as a man who but still still pretty pretty good of and that's true unless we want to accept binding because it makes sense that the program run as slow as the have with the set trace so far the biggest difference between them at a tracepoint API suggest punk is that the binding is evaluated lazily so we don't spend lots of time and the 2nd API I was talking about is the rug inspector and it's also about being lazy so when you have such a strong core and and who you need to our continuously maintain all your frames a list of the frames and are continuously captured the state of the art from machine to understand what's going on and up to presented the the present of all the frames at the time you hit the breakpoints with the bad inspected is and so I went reach the break point we can just call the the by the spectra opening and then our Kullback will receive an object with the up backtrace and only 1 the M internal information about the but you may the have others that it's also see API and as we know from the
previous slide so if there is the API than we have probably a wrapper jam for I that and now it's obsolete well not others a pretty hand the bog inspection genome and if you want to access all those API from a from really it's quite easy to do so
so just this goal part by this picture open and you get your object and you get your collocations and how you can get the binding so from the frames of Proc class and stuff like that the only limitation of 4 of these API is that you can't use are the objective that you get from the from from the block I can't use it outside the block so if you for example need a to access the binding so also the block you need to capture and sort them so what our here comes a small
performance summary we get 5 seconds with the simple program run Our centuries Frank is really really slow it's 2 minutes and Eddie Van Hook is super fast and tracepoint is in between I should and then it's a it's possible to get the almost the same performance so far with tracepoint as we get that the Iran hook of when we're using DEC block so because unfortunately when we run the debugger we have to watch for all events and now as you have seen up this is the small program generates 9 events per like do calls and that's a lot for foreigners that's a the bigger so our who is using what so such as farming is actually used by the debugger be I ordered comes with the op Ruby interpreter and that's why it's so slow mn event hook is used by VBD by Bayes and debugger jams review by base is basically the fruit debugger frontend for a bit about and I knew that I need and but but it's also used for other tough which was used to capture coverage shirt for 1 . 8 until we got some Suite coverage API that's used by simple and the tracepoint users of and the by this picture are used by the Bayes why Bob and binding of colour jam was so there things 2 . 0 only on the basis the genome is a front and for arms about IT but it seems that under the hood everyone everyone is
using a ending and folk because centuries from the generates and you hook which is executed on every event and a the market that generates the binding are you really of and citrus find is doing the same but it generates the objects are which is which evaluates binding lazy so power let's continue speaking about being lazy
I love being lazy but you know what you're cp also love being lazy but if you don't know who she moved to too hard he can do things faster of us so with the trace API we still have to check on every year and that we are in the on a break point line or not so our that's of that adds a pretty big performance impact so I will I was measuring these all this stuff with empty hooks and you can imagine if you went to check on every event is going to be even longer so I here comes a Robinia's
because in the various it's you don't need to do our check explicitly for a line in the file of what you do is basically you kept it when there's your strip is compiled you get the any and diffusion look and you get the instruction for up for for that for that particular so here's here's how looks the debates section for a minute this
Google hook is called when the script is compiled and reaI checking that this script matches our felt that and if that's so we'll look at in the line of of for for a given the occasion look for our line and the instruction pointer in the the finding that we just sitting on break point and that makes Serbia's debugging super super fast like here is the comparison between simple brought and then the full debugger enabled because we don't have to check a basically anything and our break points are called the at the moment we are reaching that so it would be the cool if we could have such API in Ruby so basically I think
that's all I know about the review by Europe so you may find me on Twitter on and you and you can take a look at the examples and the benchmarks I was using during this talk and maybe experimentally validated and see what's what's going on inside of the order of the the number of the of the of the of in and some of you
Sampler <Musikinstrument>
Gerichteter Graph
Skript <Programm>
Metropolitan area network
Suite <Programmpaket>
Güte der Anpassung
Kontextbezogenes System
Digital Equipment Corporation
Motion Capturing
Ordnung <Mathematik>
Objekt <Kategorie>
Klasse <Mathematik>
Wrapper <Programmierung>
Open Source
Virtuelle Maschine
Weg <Topologie>
Objektorientierte Programmiersprache
Demo <Programm>
Elektronische Publikation
Offene Menge
Fortsetzung <Mathematik>
Kartesische Koordinaten
Kernel <Informatik>
Arithmetischer Ausdruck
Hook <Programmierung>
Funktion <Mathematik>
Lineares Funktional
Funktion <Mathematik>
Kombinatorische Gruppentheorie
Framework <Informatik>
Kontextbezogenes System
Ganze Zahl
Front-End <Software>
Wrapper <Programmierung>
Inverser Limes
Zeiger <Informatik>
Operations Research
Leistung <Physik>
Dämon <Informatik>
Objekt <Kategorie>
Brennen <Datenverarbeitung>


Formale Metadaten

Titel Ruby Debugger Internals
Serientitel RailsConf 2015
Teil 67
Anzahl der Teile 94
Autor Ushakov, Dennis
Lizenz CC-Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben.
DOI 10.5446/30699
Herausgeber Confreaks, LLC
Erscheinungsjahr 2015
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract How does a Ruby debugger look and work on the inside? Is it difficult to write a debugger? Hear the full story of supporting Ruby 2.0 straight from the maintainer of the RubyMine debugger. In this session we'll expose debugger internals, including different APIs used by debuggers; review how they evolved; and look at what it takes to keep the performance of a debugged application at a reasonable level. We'll also talk about alternative implementations including JRuby and Rubinius.

Ähnliche Filme