Debugging visually with >>,>,> |, ||, | <, <, <<

Debugging performance issues using a standard debugger is almost hopeless because the level of detail is too high. There are other ways to use the profiler, but they rarely give me good information, especially when it comes to the GUI and background threads, since I never know if the user was really waiting for the computer or not. Another way is to simply use Control + C and see where in the code it stops.

I would like the Fast Forward, Play, Pause, and Rewind functions to be combined with some visual representation of the code. This means that I can configure the code to work in fast forward mode, until I go to the GUI in a critical place. Then I set the code to run in slow mode, while I get some visual representation of which lines are being executed (maybe some kind of increased representation of the code). I could, for example, set the execution speed to about 0.0001x. I believe that I would get a very good visualization in this way, whether there will be a problem inside a particular module or maybe in the connection between the modules.

Does it exist? My specific need is Python, but I would be interested to see such functionality in any language.

+6
source share
3 answers

The Fast Forward to Critical Spot function already exists in any debugger, it is called a breakpoint. There are indeed debuggers that can slow down the execution, but that will not help you debug performance problems, because it does not slow down the computer. The processor and disk and memory are still as slow as before, all that happens is that the debugger inserts delays between each line of code. This means that each line of code suddenly takes more or less the same time, which means that any trace of the performance problem is hidden in it.

The only way to find performance issues is to record every call made in the application and how long it took. This is what the profiler does. Indeed, using a profiler is difficult, but probably not the best option. Theoretically, you can record each call and time of each call, and then play it back and forth with fast forward, but it will use an amazing amount of memory, and in fact it does not tell you anything more than the profiler does (indeed, it will tell you less, as this will miss some types of performance issues).

You must be able, with the profiler, to figure out what takes a lot of time. Note that this may be due to some calls to functions that take a lot of time, because they do a lot of processing, or it can be system calls that take a lot of time, something (network / disk) is slow. Or it may happen that a very fast call is called a load and many times. A profiler helps you figure this out. But it helps if you can enable the profiler only in the critical section (reduces noise), and if you can run this critical section many times (improves accuracy).

+4
source

I assume that there is a stage in the application that takes too much time - i.e. makes you wait. I guess you really want to see what you can change to make it faster.

Used technique random suspension . You start the application under the debugger and, in terms of its execution, make you wait, pause it and check the call stack. Do this several times.

Here are some ways your program can spend more time than necessary.

  • I / O that you did not know and did not need.
  • Very often select and release objects.
  • Track data structure notifications.
  • others are too numerous to mention ...

No matter what it is, when it happens, a call stack check will show it. Once you know what it is, you can find a better way to do it, or maybe not do it at all.

If the program takes 5 seconds, when it can take 1 second, the probability that you will see a problem at each pause is 4/5. In fact, any function call that you see in a few stack examples, if you could avoid this, will give you significant speedup. And thus, almost all possible bottlenecks can be found.

Do not think about timings of functions or how many times they are called. Look for lines of code that often appear on the stack that you don't need.

Example Added: If you take 5 samples of the stack, and a line of code appears on them, then it is responsible for about 2/5 = 40% of the time, give or take. You do not know the exact percentage, and you do not need to know. (Technically, the average is (2 + 1) / (5 + 2) = 3/7 = 43%. Not bad, and you know exactly where.)

+1
source

The methods you describe and the many comments seem to me to be relatively weak probabilistic attempts to understand the impact of performance. Profilers work great for graphical interfaces and other inactivity programs, although a little practice is required to read them. I think that your best choice is, though - learn how to better use the profiler, for which it is needed.

The specific use that you are describing would be to simply connect the profiler, but not to record it yet. Go through the graphical interface to the point in question. Click the profiler record button, complete the action and stop recording. View the results. Fix Do it again.

+1
source

All Articles