Author Topic: modifications on the profiler plugin (cosmethical)  (Read 10291 times)

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
modifications on the profiler plugin (cosmethical)
« on: October 07, 2009, 09:56:30 pm »
Hi everybody,

I made some changes to the mentioned plugin.

I gave the window an overhaul. Now the listctrls are the windows that grow, the helptext below stays put. I put scrolled windows instead of of grid sizers, so there is a sash to resize as one prefers. I change the background color of the help texts to to make them less important.

I added a functionality to the call graph list: activating an item by double click now jumps to that function in the call graph and selects it.

Did some changes in the wxProgressDialog. The dialog took much longer to update, than time needed top parse the underlying data, so I changed the update interval to a fixed setting. Every 1/30 of the underlying data parsed -> on update on the dialog by an according step. It now works very much faster. And I quit the dialog for the gprof call. Just wasn't necessary.

Did some code refactoring too, passing arguments as const& and things like that. I don't know if these changes make the code clearer or faster, but I like it better ... :mrgreen:

Fell free to use the attached diff file and please give me your comments on the changes, in the end I'm still a learning beginner and very fond of critics ... :wink:

Regards

nausea

[attachment deleted by admin]
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: modifications on the profiler plugin (cosmethical)
« Reply #1 on: October 07, 2009, 11:00:52 pm »
Not tested, the patch... but will do it some day...

The biggest problem of the profiler dialog  for me is that it is modal, it stays on top of C::B and you can't click anywhere.
Can you make it modeless (I think I didn't see it in the changes description) as you are on this topic?

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: modifications on the profiler plugin (cosmethical)
« Reply #2 on: October 08, 2009, 01:05:06 am »
Hi,

actually I'm not on this topic, really ... I'm a very casual programmer and things like this patch are rather born out of interest in learning something. So I get a peace of code small enough, so it doesn't scare me right away and that I think I can still handle it and understand it, and look into it. Motivation is always that it is a peace of code which I actually use when I do some programming and so I think about it, and about the things that would be nice and if I could change the code to achieve it ...  :roll:

I would like to implement some more changes... I think the profiler dialog should be a tab at the bottom of the editor window, so one could directly look into one's code while profiling and jump to the actual functions directly. I will try if I can get this figured out, but I can't promise anything as I have a "normal" work too, and that's not programming :wink: ...

Another thing that would be nice would be some graphical statistic, ... or even a sort of history of profiling a piece of code ... it would be nice too, if working in a target witch is a profiling target that this could change the user interface like hiding the tabs below that are not necessary ... I letting myself being carried away ...  but luckily the profiler plugin isn't that important nor urgent, not like code completion anyways ...

First I would want to wait if my changes "pass" and get an OK from the "senior" developers ...

I'll give it a look. Would you just prefer the same dialog, just that it wasn't modal, for a start ? I think I can do that.

Regards

nausea

PS: as I already found a small error in my code, I will be looking into it anyway.

CORRECTION: no error. this was due to memory failure on execution time. That is: MY memory and the advanced hour of night
« Last Edit: October 08, 2009, 10:17:40 am by nausea »
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: modifications on the profiler plugin (cosmethical)
« Reply #3 on: October 08, 2009, 08:48:58 am »
PS: as I already found a small error in my code, I will be looking into it anyway.
...which one? So does that mean it is not safe to apply the patch at the moment?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: modifications on the profiler plugin (cosmethical)
« Reply #4 on: October 08, 2009, 10:14:48 am »
No, the error I had in mind, is not in the diff file. It was a mistyping in a section with additional parameters for gprof in cbprofilerexec.cpp, I though I had exchanged by error the "-m" parameter but it is all OK apparently. Just woke up and checked it (I'm in Spain time-zone  :) ) ...

So it should be safe. At least it is working fine here on my machine, as I can tell. No weird behavior and the parsing result of a gmon.out file I used for testing does not differ from the results parsed from the same file with the svn version.

Regards

nausea
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: modifications on the profiler plugin (cosmethical)
« Reply #5 on: October 08, 2009, 12:27:07 pm »
By the way, I think there is a crash condition in the profilers configuration dialog. (I don't think that it was introduced by me though, as I didn't touch that functionality) Checking the option "file info" lets c::b crash on execution of profiler plugin. I attached the crash report.

So I checked the other configuration options too.

- "Brief" doesn't seem to change anything in the output
- "File info" crashes c::b
- "Annotated source" I didn't try
- "No static" didn't change the output
- "Minimum count" doesn't seem to work as aspected, the output is not changed and the number is only settable up to 99
- "Sum" took a long time showing a busy cursor but at the end the output dialog doesn't even show. I think I simply don't understand this option

Is all of this work in progress or am I getting something wrong?

Regards

PS: it seems strange, that the file format of the crash report is not an allowed file type for attachment ...

[attachment deleted by admin]
« Last Edit: October 08, 2009, 12:40:36 pm by nausea »
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: modifications on the profiler plugin (cosmethical)
« Reply #6 on: October 08, 2009, 03:23:53 pm »
Is all of this work in progress or am I getting something wrong?
The crashes all appear here:
cbprofilerexec.cpp:265 with the following code:
Code
if (!(count%STEP))
...with STEP being calculated like:
Code
const size_t STEP = maxcount/RATIO;
As you see: This can go zero, which is no good and surely will result in a crash (division by zero).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: modifications on the profiler plugin (cosmethical)
« Reply #7 on: October 08, 2009, 03:33:01 pm »
- "Brief" doesn't seem to change anything in the output
- "File info" crashes c::b
- "Annotated source" I didn't try
- "No static" didn't change the output
- "Minimum count" doesn't seem to work as aspected, the output is not changed and the number is only settable up to 99
- "Sum" took a long time showing a busy cursor but at the end the output dialog doesn't even show. I think I simply don't understand this option
For these inspect the documentation of gprof, e.g. here:
http://unixhelp.ed.ac.uk/CGI/man-cgi?gprof

These parameters depend on the executable you are profiling and may have no effect, indeed.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: modifications on the profiler plugin (cosmethical)
« Reply #8 on: October 08, 2009, 04:05:23 pm »
As you see: This can go zero, which is no good and surely will result in a crash (division by zero).
OK... some more tests... the RATIO was not a good idea at all I guess. Why did you implement this? If there is no good reason I'd prefer the way it was before.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: modifications on the profiler plugin (cosmethical)
« Reply #9 on: October 08, 2009, 08:28:34 pm »
Hi, thanks for the replies,

well, good catch, I feel a little bit dump having commite exactly that stupid error. The division by 0. Almost the first thing you read in every text about programming errors ...

The reason why I wanted to chang this is that the update of the wxProgressDialog, as it is now, at least on my project with has about 30 files (so it is rather small), slows down the whole thing. If I comment out all the updating of that wxProgressDialog, the plugin parses my project in about one second. Whith the wxProgressDialog as is it takes about 10 seconds. I wanted to speed this dialog up having it been called less and updating each time a greater chunk of the gauge, not having it update by one step for every line of data that gets parsed ...

The idea of using all that (not very bright) division by zero code was to update the gauge in equal steps in relation to the number of lines that get parsed, that is to say, no matter what the size of the wxArrayString containing the data it will always update the wxProgressDialog in a fixed number of steps (like 30 updates or 20, or what so ever ) which would be calculated by the part

Code
const size_t STEP = maxcount/RATIO;

I guess I just realized that the modulo is still a division. But I still think that updating the gauge for every line parsed is not a good idea, serious ...

That -m option : is it right that it refers to the non standard c and c++ extension of basic-blocks ?? I'm not sure, but I seem to remember that gcc does not produce any basic-block profiling information when profiling ... but I'm surly wrong there, and besides I don't know about other compilers.

Well, these were my motives. Thanks for the punch on the nose  :) I will think it over and try something better. What do you say of the rest of my changes ?

Regards

nausea
« Last Edit: October 08, 2009, 08:32:57 pm by nausea »
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: modifications on the profiler plugin (cosmethical)
« Reply #10 on: October 08, 2009, 08:44:16 pm »
Without seeing the code you could try:

Code

for(int i = ....)
{

     ... work ....

    if(i % 100 == 0)
         progress->update();
}
progress->update();

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: modifications on the profiler plugin (cosmethical)
« Reply #11 on: October 08, 2009, 09:02:04 pm »
well, good catch, I feel a little bit dump having commite exactly that stupid error.
Don't worry. Devs make mistakes... all the time, all the day. ;-)

If I comment out all the updating of that wxProgressDialog, the plugin parses my project in about one second. Whith the wxProgressDialog as is it takes about 10 seconds.
Ok - I got the point. So... if I use i % 10 then it should be called 1/10 times, which should lead to the same ratio.

but I seem to remember that gcc does not produce any basic-block profiling information when profiling ...
Might be true for GCC/MinGW. But probably other GCC variants (Win, Linux, ARM, PPC, whatever...) do different. C::B supports GCC variants quite easily. And with every GCC comes a gprof usually. So we better leave that option. ;-)

What do you say of the rest of my changes ?
They are fine with me. I am testing them and all seems to work fine. I'll probably commit the modified variant later (not today anymore).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: modifications on the profiler plugin (cosmethical)
« Reply #12 on: October 13, 2009, 01:33:39 pm »
Hi Morten,

I looked through your changes ... shouldn't it be

Code
i % 10 == 0

to achieve 1/10 times update? If you only check against

Code
i % 10

I think it's nine times update and one time skip ...

Regards

nausea
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: modifications on the profiler plugin (cosmethical)
« Reply #13 on: October 19, 2009, 11:42:24 am »
Code
i % 10 == 0
to achieve 1/10 times update? If you only check against
...erm... yes?!  :lol: :oops:
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ