Bestand wählen

Where is the bottleneck?

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Erkannte Entitäten
among and that's what is an instance of having working there since November from the last year and recently I was working in research which was about the algorithm optimization and simulations and stuff so that's basically from all experience comes from I hope you find some interesting so and I don't have to see people with their forms like throwing people was to so let's start so 1st of all like
like with the basic level in the topic I wanted to try and I will close with a strategy what I usually said before trying to optimize the new program or not and key points I've learned through all this experience and then I'll just show some tools I'd like to use for me they really useful and I will go from operates operating system tools with the like they 1st there are still some resources resources tools like memories to be that and then some more unseen that I call them not bonds because they what's that than just taking 1 so the war in this is there the slide with the most text In the presentation so promise it will be just this once I so that main people and I like to say when I start with a new is that OK so the first one is called so when I start taking a new program like to see of my head it's like to think that what exactly what I wanted to which is the degree of acceptance like I wanted to by optimizing this new York because sometimes like just happy about optimizing the problem the and raise the speed up and going to make it faster about that and you end up being sold the beginning sort what she like you know like use Monday optimizing the problem and then you you stand up on your teammates series you like weekend Menelaus's that is linear in still struggling with it so next people in these costs life is there a musician we're going to to the the like the company's paying you money in Florida you're like with the time and for example if it's a speedup of just winning some units for its execution and that's which and takes some men that's what they say the customer the focus on the by related and then the 3rd 1 is called all if some of you have been through lexical sometimes see like these bonds of that it's like a mean what what these guys programming in Python and doing this the 1095 when you have just like building functions like all for what's more these comprehension so this kind of stuff so the 1st I studying optimizing the code are you should if it's not difficult we so that's like why is telling I mean because in Mexico believe me you change 1 line 1 being too much stuff is starting to happen there also a context awareness of a vector on the same day so context aware this is related more like the control all the environmental things you're trying to optimize is this call or you depend on random stuff going around 1 megawatt we so random stands like network issues or my SQL queries that sometimes take random time so before trying to optimize With this noise issues like be isolated from this I'm optimizing this quasar and there were performance started skated with analytical beaches go into that and the last 1 is local context so sometimes you just start and you say combine optimize that I am doing i get and start calling and everything and you spend like 2 days calling and then you will that's of elections you obtain it like half like half time for example the code you move into bed and it makes you more times Y. you know you don't know this may be because the pharmacy and staff and their resources difference operating system kernel version of whatever so before starting set up an ice and written using past much as you can and if it's not possible bonds just wait 2 days for moving you cannot relax and we iteratively so you can have feedback so that's after 3 years of working with this kind of stuff on I'm to multiplying all of sometimes but I think they're really important points that can save you a lot of time if it's like the 2 of them to the FIL here you can see my skills in design so user right to approach these from there are also part to the you know what so usually when I start with a new called this try to but let's take how much how long does it take to to execute once we know how long we also want to know the source signals you like memories the you on this campus and then when you have these 2 things because like the thing you have to do then is to understand why why is taking that time and if it's taking this time is a normal to consume all these resources and to that have to have the cold it's we talked before like because you know you have to know what the problem is doing this way you know it's reasonable or not to the constant all the so once you understand the cold you can just start writing for like going in more inside understand 1 thing I want to commend is that when you take 1 code you know only measuring time measuring resources and all staff we apply to the whole called but if it's your call usually know which like which is a problematic particles so you just go to monitor that Of course once you apply the goal of part of you just have to execute against you you know you don't mess up with whole execution but that's basically the floor I usually this so let's start with pretty basic tools and all you know them but for me the most interesting ones and the 1st thing do maybe the 1st 5 minutes is used in time and age solve for thinking how it goes the thing I like usually for for time is detective my program is really resource bond or ideas because I don't always know how many of you don't know all the time so it so basically the upward gives you is that their execution time in CPU and the completion time of the user so if you have many blocks blocking stuff like a network where it is or might SQL queries will tell you like which is the difference of so we it can give you an idea of the all the things program is doing then this case stop basically what I studied using because that is what they mainly started using Mac From analyzing have take the output of which is have to president of the you how to get
so if you take the output of thoughtful man it's like I mean if someone can read something about that you are a rare Pokémon because is like messy and noticed realignments it's pretty much the
so if you go with it stops and it's community listed on this slide CPU it shows you 4 different processes of memory and others services really
it can you few already in all that so let's go to 0 so more of the more
interesting stuff and so 1st one
memory profiler is 1 quite interesting because it allows you to saying the whole flow of the program like the memory consumption for the whole function-oriented by all this so just to others and other features interesting future that 3 other by the once you've reached a maximum capacity for memory so you can't sell when executing like if the memory and using is more than 1 gigabyte or 100 megabytes John meaning to the bullet consoles and then take the status of the prior and the objects you have initialized so this some
examples of the output that's why we've got 1 for example i'm here if you can see from the like I don't know it shows you like the example we have 2 main many late 17 seconds and then we have 1st call function and 2nd costly function and it just marks you where it's functioning stops so it gives you an idea of the whole program which is a function of the function you should focus on like to we will improve their memory consumption which sometimes can a so as another sample here we have that I mean output for just taking their memory consumption which is kind of interesting to this 1 is really so if like 8 times more them for 1 time pretty enough so let me show you the only
does anyone know how to move the terminal to present the are
usually not just because I don't
want to be out of all of well
so the primary use for that condition from the back so so they're parameter used as a test is now 1 so I mean you've already seen the graph but when I was 1st trying that I follow that this prime would take much moral memory that at trial division because of their big number and stuff but it was result the other way so we does this basic tool you can test structure is a full information and by something something interesting to having your tools so the the next 1 is
for the other source which is called low profile you know people in Python usually we go with equal mental so there really original so this 1 is an advanced motion of C profile typify was beauty profiling tool for Python and presenting it that because it was the 1 who's always but basically it's is a Fulton all their CPU consumption at time of brands it shows you but a line or function on the average that's what percentage of consumption of time consumption of lines your functions and the it's compatible with the profile of code it's that something interesting I found out that I mean something to start profiling and those profiling tools like multiply that they're not sufficient and then you profiling and you get the stuff set 5 years and then you they consul and usually with some kind of tools you lost all the progress because the report is generated at the end without 1 just generates what the it's been displaced you want it calculated from from that such pretty recall so that the
example of the output for that 1 is the same coal and for example here you can suggest that the execution time like a person based on the number of features for its line time in total on the time working so for example here we can see which is a problematic function to like this 1 is 1 have grade of money of all of their 1st cost function which he wanted to do Gold like technical like which 1 we want to optimize who got the theory for that so as I recall it also there is some time to execute with full called I mean if you have a cold that takes like I was using this what kind of like it's too long to use them and it's long because really you have to monitor the whole and if you have done this kind of stuff sometimes it's a B what difficult because you have to modify your source cold and and what their profile the go into it was there so you want to monotone functions you have to use that decorate or then you have to change the source code and then you execute you realize that that wasn't the function you wanted to profile then you go to another function you have to execute again so it's kind of so that's where soup IPython
don't to so I buy that's my profile on memory profiler supported as plug-ins for and that's we equal because it allows you to profile any function in your cold or source code of any of library interactively so you have to execute the full so just let me show you 1 of the example
upwards but now we will play a bit with it so when you take on the top of the screen we just using the Load extension like a file then I'm importing my program and then using their common magical that around with the function I want to profile which is the minus that and then the problem calling which is brought about what problem out that 2nd of course the function that so here we are having the report for the line profile weights it's level 1 level deeper than we had previously just monitoring for the outside function so here we can see that y is the 2nd call the function more costly is because it's indeed calling these tennis method which I don't know what is that thing is something with prime numbers but that's the 1 that it's actually taking lot of time so here we have also kids the time the Burkitt's I'm and the amount of time it's consuming which is what we want to actually what we so just to show you that lighting so far from so the go so if we
go to only the 1 on the and
then some he wouldn't talk then I'm
using the load fixed line profile then from I'm import there a 2nd costly functions and then from the audience now we are going to introspect their interest in its function without starting out source code so you can say how easy it is to take how much time its line of the Oedipus function is spending so from our audience but my thoughts but knew that already sometimes you will have to take in the source code where its function is you know that so we're are importing this function unknown we are their out there and we want to profiling and at dolls and this function and we're gonna run again there 2nd costly so now we are running their 2nd only financial monitoring the time that it at Austin taking so 1 is that 2nd now it's taking on like and seconds of stuff so what is the the function to about 2 hours really it we have to a always way like spend 2 hours so just to check the cost of their interest in a function that's not a good thing we have to we can go just of constitutional history for an hour so we can just called the customers function by itself by calling it with random acts and which will you ask report as fast as you is just 1 iteration because in their original programming was continued right 800 thousand times which is not necessary to have basic profile of the so we can see again here we tend the functions that are like what constant functions what operations about the most time consuming so if that was a real problem we want to optimize we would take like those ones are really groups we what we and these operations the most optimal ones and stuff we're not we're not going to go into these details but now at least we have spot where we want to do all our stuff and I mean for me I pretty handful or doing this think interactively
so back to the presentation all I'm pain
some of you have worked with that already I mean come on like if you search for profiling in by phone line prefinal remember profiler and this kind of tools on the 1st one you all the 2nd part of the
presentation which I call I call the advancements more qualified tools that displays this well enough so you can play more interactively with them which I mean call police enlisted looks call for so the first
1 I like what kind of love and hate at the same time you will see why but is this 1 called plot it doesn't have much come on it's not that I must anything but it that's it's warm so the fact the features it has is that it's really low overhead profile so why is that because it uses the estuaries and of function from the airport operating system which basically just read the back of their executed so it doesn't interact with the problem like we've seen with memory profiler stop with just would stop in the middle here so it doesn't use back analysis money basically this place called out of Fourier functions holding between them and the time spend with them and it also displays graph which part of knowledge you know what it is but it's something we define for example the Netflix they're using a knowledge you follow they're not but it's pretty useful so there has a server running with Toronado and with this and said that you can just feel this we were sole you can up of no this is a limitation in reality we don't so to show you this the
aims for example here we have that provide that's when it hit the program because it means that the cold adapted to the missing and then if you wanna like to just all this stuff you have to play a bit to like what will be the it's like in the better so it's kind of situation but here we can see that there was this function is indeed the 1 to the most time on the main is with along calling 2nd qualifying some of 1st of the function so we can see the flow and then we also see the size of the of the width of the arrows is the time spent also calling this action so it's pretty useful and also with the flame graph and I know you don't see anything here and explain it to so it's the same right here individual have the main function of the main function calls 2nd commonly found and 1st probably function so you have to go from bottom to top on the way of the blocks in the tells you how long it take to execute this section so here at the bottom of the see that meaning to 99 per cent of these and goes to the school to 89 per cent so that's pretty cool and initially why it's called flamed out because with a real
problem looks like this allows us to have but you know have to write a rate of the learn how to isolate stuff so so the next 1 on its goal but I
formant running out of time so I'm gonna skip the cold had prepared by you can reach me out that later so by 4 months it doesn't have fancy graphs but it's critical because I bed you have done a lot of these typical from time import time start time time about that time and then we'll some stuff and time time time and then we applied a substraction and a new ideas stuff so Italy by from and this set of tools that with context managers and this kind of stuff it gives you like how many times a function has been called hello long it to a function to process how many this 1 is really interesting that measure rate of fragments over time so it tells you how many times a function was called during the last 2nd during the last minute during the 50 minute so this is really cool for generating metrics for maybe at for this kind of stuff so it's not exactly I interact the for some optimization like for taking their profile but it's more like for generating matrix so you can just monitor how your application is going something that's stating time into account that these timers which are the ones measuring rate of events I should variables so you have to be aware that if you are using threads and this kind of stuff it uses locks internally so we can't end up being a mess if you don't do it properly so that it would have about the mother of all the slides and I want to pretend this last 1 which is people basically so this last 1 is called data this 1 was originally for providing C and C + + in the research 2 other job I had I was doing the best + stuff and that's the 1 I was using for optimizing all these pointers operations and think it I really all tool I think in 2000 2 words so it's just users while in this place you they're calling it displays execution time it displays blob of them and then for the functions also the time cost for lines which is not true in Python hosting simplest lies I would have to make it work properly in Python that thing I want to it and it also place assembly code which of course I use every day and it reads from the profile of using this tool which is by so thus the text of the output this
is the goal that we have from the emperor show just through and instead of showing you an image that open the form so you can see particles so but
have these profile already generated but basically what you have to do is called Europe program with that a
simplified model which will output the profile information and then you have to
convert it to a local green so called income what OK that's a green can understand it school with killed because in OK it doesn't work you have to use the q yeah history with so here we
have use so basically here we have the other functions that have been called in our program we want to take the ones that we basically control we are not going to optimize the not as square root of biphone we are not going to what part the plan for that so we wanted we just want to take the manifest s and the ones we actually prior so in that you we have been ordered by the closing time that it takes so the main has taken 100 per cent of obviously and then have like from the most time consuming to the last time these here so if we order ourselves will see again that that is the 1 that consume more time so we can go for example here and he thank you we want to select maybe OK so In the 1st 1 it's a fast this so rather than ordinary here and all this stuff in the top right plot we have a which just let's ask usually check which of the front which is the function of the function that they can most time to execute it is like having just 1 by 1 so you can take OK here's the problem and in their bottom right plot we have the of our program flow so we called me at 1st and then main goal 1st column of a so and single because function and then 1st function called these prime 2nd goes refer to all trial region and all of them called and at Austin and again liking the block tool we have the size of the Aral and these thing here that tells you how much time was spent calling that each of which is also the same and then that 1 x is how many times we call but so that's a really interesting to another thing about I really like in the model when I was from last thus with our obviously doesn't work but it was showing your reports of like we've seen in line file so for any function of your code that you have called it would it would display a costs while CPU time site for next to the line so you you know every line up my has taken to execute executed I'm still working on own following the divide and make it work for a so just to finish the power we have about terms I those fragments with questions or without question of then let me show you like the cold landscape the From there by 4 months 1 which is into interesting to here so now we're
going to go to the terminal so this
is a cold and that using by 4 months so basically an importing time which is a tool that given my performance so you can do with time test not time that's the shared by what I was talking about so in any other part of your code you can just access test time and the spring day mean get mad by which basically it's printing their mean time it's taken to execute that of gold the body and of their execution mean rate which is the number of executions for 1 2nd squared 1 minute wait for 1 minute on this kind of stuff it's pretty handy because I mean it's most of you had a cold and you want to keep it light you know it being executed around with 10 seconds or so so you can you just use this tool to trigger an alarm or log and so you all God this function to look like 20 seconds or something going wrong so you can use that for your performance
tests of this kind of so far corporate the best most the story this basically it's telling me that there is almost no integration because I don't know if you saw the 1st called Cypher I have here that have vesicle 0 . 21 then is beginning of the fresco it's telling me solid sufficient something wrong happened and why is that because I'm going as the in around uniform 0 called wondered about 3 weights not exactly with the parent the parent should they should be 0 . 2 0 but because of the cost of takes how so now
for finishing and if
presentation and all lot of
Brazil and the ones of cool all some of them want feed on your tool said some of them will so 1 thing is really important if or starting with this kind of stuff it's just building your course by what exactly the same by do I need this kind of tool or do I need something more advanced for the framework and using lines and the people to or if I'm using Ziemann reinvent profiler because the profile doesn't work well with them so test sites will do some kind of research before using and it's like finding in StackOverflow or who have so but greedy match all so I hope you found it interesting story at least you will learn something new so if you have any questions or it will have full time enough request and you can just waiting outside come to talk about these or any other random stuff I'll be happy to talk with you so questions be
fair well 1st of all thank you nice the just a simple question which 1 of these to use the most I so as I said about my favorite 1 is OK considering because it just I mean they're execution is really no but does by 1 it's a question after full view of what's going on in the program thing is that since I don't have this idiots and after that execution usually at the end of a using line profile for that interact interactively with iron because once they have the big picture and then I'll OK that's a function that it's using of I'm going to call to the IPython I call it manually so I know weeds client exactly inside that function problematic 1 so that's basically the 2 of them but the other 1 satellite also to use them because sometimes by using different tools by just using 1 so sometimes you just you have a narrower view of what's going on so by having different so sometimes we recently in graph form these blobs staff for any of memory for example you have more the picture of what's going on because we don't want to you don't see all of the and suddenly there is no to that both everything so that after doing with they think you know that this is some minutes for questions a very interesting so and you do have any advice on measuring the performance of an ongoing process like long the running process so something like that so you mean something like API or a yes and endangering the but meaning this so I mean that to kind of things here for from a long-running processes can be simulations using and research that and the like what we call or I don't know what that so for those kinds I I'm blogging states are really important 1 actually for example this by 4 months when I've shown you it's really interesting because then you can have the back of different metrics inside the by how many calls how many times have you call this function you know is that big 1 is the number of calls the extent to the 1 you were expecting or not so that's for 1 side and for the other 1 for example EPA calls and this kind of stuff I was said by 4 by formant is already also an interesting 1 because it can't tell you like how many times this endpoint has been called all this kind of stuff and the problems I'm not using it and last services and products and services but I know people in like they're using ancestral know how stuff is building like this call graph building right during the execution you have to set up because the comments and showing the presentation for the whole process so you start to monitor and then it ends and creates a file so you can open it but it has context managers and this kind of stuff so you can open the file I resisted the activity grows the file and then call another function to do this and so this file gets dynamically and ample before so then you you can take the it is always a from time to time so to see how it goes so but for me basically a most interesting bias longing for ones a have no if it was you're
hi interesting talks thank you and the line or the memory profiler do they also with with our course all this command line parameters so really command line parameters this with is my like command line my my striptease working in command line and expects parameters and the to the mix of 4 tool that you would you called it was in mind because the in there because of their and prove you think so you can call it that way then it will just monitor all the integrated functions we state last time but they can also colored with all my life and so you do by phone line manuals and memory profile and in your car with all their arguments here using for your screen and then it will it will work anyway so they they still 2 ways of calling so OK thank you very much
Quelle <Physik>
Betrag <Mathematik>
Ungerichteter Graph
Radikal <Mathematik>
Metropolitan area network
Vervollständigung <Mathematik>
Gebäude <Mathematik>
Profil <Aerodynamik>
Kontextbezogenes System
Dienst <Informatik>
Einheit <Mathematik>
Rechter Winkel
Grundsätze ordnungsmäßiger Datenverarbeitung
Automatische Handlungsplanung
Content <Internet>
Abgeschlossene Menge
Arithmetische Folge
Diskrete Simulation
Konvexe Hülle
Elektronische Publikation
Wort <Informatik>
Prozess <Physik>
Kartesische Koordinaten
Kernel <Informatik>
Einheit <Mathematik>
Prozess <Informatik>
LASER <Mikrocomputer>
Mixed Reality
Wurzel <Mathematik>
Funktion <Mathematik>
Lineares Funktional
Nichtlinearer Operator
Plot <Graphische Darstellung>
Arithmetisches Mittel
Strategisches Spiel
Overhead <Kommunikationstechnik>
Web Site
Total <Mathematik>
Gewicht <Mathematik>
Interaktives Fernsehen
Kombinatorische Gruppentheorie
Iteriertes Funktionensystem
Kontextbezogenes System
Framework <Informatik>
Physikalische Theorie
Inverser Limes
Zeiger <Informatik>
Leistung <Physik>
Matching <Graphentheorie>
Elektronischer Datenaustausch
Physikalisches System
Objekt <Kategorie>


Formale Metadaten

Titel Where is the bottleneck?
Serientitel EuroPython 2016
Teil 20
Anzahl der Teile 169
Autor Miranda, Manuel
Lizenz CC-Namensnennung - keine kommerzielle Nutzung - 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/21180
Herausgeber EuroPython
Erscheinungsjahr 2016
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Manuel Miranda - Where is the bottleneck? We all know Python strength does not rely on its performance and speed when running programs. This plus the flexibility of it, can lead to build real slow and bad quality software. In this talk you will discover a set of useful tools for diagnosing where the bottleneck is in your programs along with trips for quickly realizing which is the most needed resource. ----- Have you ever felt like your software is eating your resources and you have no clue why? Have you reviewed all the lines, debugged and printed everything but you still don't know what's wrong? In this talk I will conduct a fast intro of a basic set of tools you can use to diagnose your software's performance and then we will go through a simple piece of code to show how those tools work and what you can expect from them This set of tools will include basic ones given by the OS itself like `htop`, `lsof`, `ps` and more advanced ones that let you plot the memory usage for given functions like `memory profiler`, check CPU usage and the call graph between functions like `cprofile` and `kcachegrind` and others. By the end of the talk, you should have an idea of which are the most typical causes that can make your program slow and you will have a list of tools to search for and identify the source of the problems.

Ähnliche Filme