Code::Blocks Forums

User forums => Help => Topic started by: sque on April 13, 2006, 04:57:20 am

Title: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on April 13, 2006, 04:57:20 am
Hi!
1st of all, REALLY Ty for this great IDE, although it is still under development it is a much promising project and it is something that was missing from the free community :D

My main prob is that code::Blocks works slow on linux (the widgets rendering part). I have compared the same version 1.0RC2 on windows and the speed is uncomparable.
More specificly the scroll inside the editor (and on th project browser) is jerky -laggy. Also If I start typing something my cpu pops to 100% (this may be code completetion related but it may be rendering prob again).
Another example is that if I change virtual desktop and return to the one that Code::Blocks is opened, the window of Code::Blocks  takes about 1 sec to rerender every part of it. I know that the values (of time) that I am complaining are quite low, but why on Windows is so much faster?

I tried the latest build too (11 april) and same results.

Notice: Similar behaviour had Firefox on my machine (It is an ubuntu package bug of firefox) and I fixed it by setting a enviroment value to disable firefox to use Pango. I am just saying it in case that maybe a similar bug(?).

I hope to see it fixed sometime, till then I will keep up my work on Code::Blocks as it semi-rocks (code completition must be finished :P ) :)
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: takeshimiya on April 13, 2006, 06:08:42 am
Can you confirm the 100% cpu thing happens also with other Scintilla based text editors? (ie. SciTE, wyoEditor, Anjuta, etc).

About slow rendering, GTK2 is not fast, not at least by default.
You can disable pango rendering as you've done with Firefox, but expect to loose text antialiasing and internationalization.
But the truth is that Scintilla without pango is so much faster, so it's your choice: fast or nice.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: cyberkoa on April 13, 2006, 06:23:13 am
I was using Ubuntu Breezy 5.10 a few days ago with the latest SVN (at that time) , very smooth and very unlikely encounter bug (though sometime will hang the session, need to switch to console to end)

could it because Dapper is still not stable yet ?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on April 13, 2006, 06:39:48 am
Can you confirm the 100% cpu thing happens also with other Scintilla based text editors? (ie. SciTE, wyoEditor, Anjuta, etc).

I installed SciTE and tryied writting quickly many many words at many highlitting modes. The biggest cpu usage was 30-40%. I also tried the same at gedit, same results.

At Code::Blocks with a slow rate of typings it gets 100%. I am not a very fast writter, but the lag is noticable. Offcourse this doesn't make code::blocks unusable but It's annoying!
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on April 13, 2006, 06:42:07 am
I was using Ubuntu Breezy 5.10 a few days ago with the latest SVN (at that time) , very smooth and very unlikely encounter bug (though sometime will hang the session, need to switch to console to end)

could it because Dapper is still not stable yet ?


I was using breezy too before a couple of days and I had the same prob. Maybe its an ubuntu related thing...

btw, I dont compile source of code::blocks, I use the .deb that you give for ubuntu distros.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: takeshimiya on April 13, 2006, 07:12:38 am
AFAIK it's not ubuntu related.
I've seen a lot of reports about the 100% CPU C::B in linux bug while editing text.

Can you confirm it still happens with CodeCompletion plugin disabled?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on April 13, 2006, 07:27:22 am
Can you confirm it still happens with CodeCompletion plugin disabled?

Almost the same results, I think, without CodeComplation, the cpu usage graph is a bit different.
I attach 2 screenshoots of the cpu usage graph.
1. With CodeCompletition
2. Without CodeCompletition

[attachment deleted by admin]
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: takeshimiya on April 13, 2006, 08:08:33 am
What's with the small-sized graphs? :)

This is a time where a profiler (http://en.wikipedia.org/wiki/Profiler_%28computer_science%29) will be highly appreciated.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on April 13, 2006, 08:16:42 am
What's with the small-sized graphs? :)

Its screenshoots from the system monitor applet of gnome :oops:
I thought you would ask to test with a profiler... but my expertise on this is limited. Anyway I promise I 'll try it later, lesson time! :)
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: takeshimiya on April 13, 2006, 08:34:46 am
I thought you would ask to test with a profiler... but my expertise on this is limited. Anyway I promise I 'll try it later, lesson time! :)

No problem, can wait.
I personally can't reproduce the bug, but I hear frequently about it.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Michael on April 13, 2006, 01:13:30 pm
I was using Ubuntu Breezy 5.10 a few days ago with the latest SVN (at that time) , very smooth and very unlikely encounter bug (though sometime will hang the session, need to switch to console to end)

could it because Dapper is still not stable yet ?


I was using breezy too before a couple of days and I had the same prob. Maybe its an ubuntu related thing...

btw, I dont compile source of code::blocks, I use the .deb that you give for ubuntu distros.

Hello,

.deb package are compiled under ubuntu 5.10 with standard ubuntu packages. Anyway, it could be interesting to try building C::B from SVN sources on Dapper (which AFAIK is stable, but needs some polish :)) and see if C::B is still slow.

Personally, I have not remarked this issue. Well, my desktop is old (PIII 500 MHz), but C::B works (scrolling, rendering, etc.) similar to many other applications.

Best wishes,
Michael
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: thomas on May 05, 2006, 12:07:36 pm
Recently, I observed that a perverse amount of update_ui events are being sent around and postulated that this might possibly be one of the reasons for poor performance on some systems.

My problem is that I cannot reproduce the 100% load problem, so it is kind of hard to find out :)

However, this still looks promising:
When moving the mouse anywhere inside the Code::Blocks window (editor, manager pane, menu bar), I get a CPU usage of about 25% (averaged over a 1-minute interval). Removing a couple of EVT_UPDATE_UI entries reduces the CPU load to 12% on the same machine.

Now, I would like those having the 100% CPU problem to assist in confirming (or not confirming) that this may be a reason for your poor performance:
Edit src/main.cpp, plugins/compilergcc/compilergcc.cpp, and plugins/debuggergdb/debuggergdb.cpp, removing all lines containing EVT_UPDATE_UI.
Recompile Code::Blocks and see if the CPU load is still that high.

Note that you cannot actually use this modified version for normal development, as it does not properly update quite a few things any more! The purpose is just to verify whether this is where your CPU time goes.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Michael on May 05, 2006, 12:27:55 pm
Now, I would like those having the 100% CPU problem to assist in confirming (or not confirming) that this may be a reason for your poor performance:
Edit src/main.cpp, plugins/compilergcc/compilergcc.cpp, and plugins/debuggergdb/debuggergdb.cpp, removing all lines containing EVT_UPDATE_UI.
Recompile Code::Blocks and see if the CPU load is still that high.

Hello,

If you temporary commit the changes (alternatively, I can also apllied the change locally :)), I can build a .deb package and make it available on my File Hosting for those using Ubuntu.

Best wishes,
Michael
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: thomas on May 05, 2006, 01:11:54 pm
Uh... I cannot possibly commit that  :shock:
With these event table entries removed, none of the menus will be properly updated, the application will be utterly unusable.  :P

It is really easy to do the modifications locally, though. Just search for EVT_UPDATE_UI in those 3 files, or do a global search.
The EVT_UPDATE_UIs are all grouped in one large bunch, so you only need to select 10-20 lines and press Ctrl-Shift-C every time :)
I did not upload a patch because it is so trivial really.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Michael on May 05, 2006, 01:25:12 pm
Uh... I cannot possibly commit that  :shock:
With these event table entries removed, none of the menus will be properly updated, the application will be utterly unusable.  :P

Yes, you are right. It will make more problems than anything else.

It is really easy to do the modifications locally, though. Just search for EVT_UPDATE_UI in those 3 files, or do a global search.
The EVT_UPDATE_UIs are all grouped in one large bunch, so you only need to select 10-20 lines and press Ctrl-Shift-C every time :)
I did not upload a patch because it is so trivial really.

Ok, I will modifiy them now, build and upload in 2-3 hours (for the .deb package at least 90-120 minutes are necessary).

Best wishes,
Michael
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Michael on May 05, 2006, 04:05:08 pm
Hello,

I have uploaded a special .deb package for TESTING based on rev2411 (CodeBlocks_rev2411_TEST_package). You can find it here:

http://www.savefile.com/projects.php?pid=547711

Best wishes,
Michael
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on May 06, 2006, 10:31:29 pm
After a 3 weeks vacations, I am back :)
I checkout the svn and compiled a snapshot to do some tests

Here are my results:
* When I open the codeblocks-unix.cbd I get 100% cpu usage for a long time ONLY when the Codecompletition plugin is on.
* I can confirm that if I move the mouse above the program I am getting 100% cpu usage too...

I will try to build with EVT_UPDATE_UI commented out to see what happens.

(My system as always... ubuntu dapper 2.2ghz Athlon XP, 1GB Ram, Nvidia 5700 FX)
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: thomas on May 23, 2006, 01:58:34 pm
I have uploaded a special .deb package for TESTING based on rev2411

Did any of the affected people ever care to test this package in all that time?

It seems like the CPU problem is not that critical then, after all...   :)
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Michael on May 23, 2006, 02:10:34 pm
Did any of the affected people ever care to test this package in all that time?

Hello,

Just one person has downloaded the package. And IIRC, the same day or the day after, I have uploaded the package.

Today, I wanted to delete it to make free space, but I could not, because of a server error. So, it is still available :).

[EDIT]: Just an update. Two persons have downloaded it. Therefore, I have now deleted the package.

Best wishes,
Michael
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on June 17, 2006, 04:59:16 pm
Taking those out seems to have no effect.  I am using the autotools build which compiles with -g no matter what I do, so that might have some effect.  I will compare the normal Code::Blocks performance on Linux both autotools and CB based builds, then I will check out the nightly on windows and report back.

Does anyone have a good Linux profiling tool that will handle shared libraries?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: TheTuxKeeper on June 17, 2006, 07:05:06 pm
Taking those out seems to have no effect.  I am using the autotools build which compiles with -g no matter what I do, so that might have some effect.  I will compare the normal Code::Blocks performance on Linux both autotools and CB based builds, then I will check out the nightly on windows and report back.
I didn't test this, but you can try to remove the -g flag in the CXXFLAGS variable in config.status (only available after running ./configure), touch one Makefile.am and then run make again. It will update the Makefiles automatically with the variables values that are stored in config.status.
Edit: Now I checked it and it works. The -g disappeared ;)
Does anyone have a good Linux profiling tool that will handle shard libraries?
Don't know whether it helps you, but I found http://en.wikipedia.org/wiki/Performance_analysis . There you find few links to profilers. I just wanted to know what a profiler is and found it  :lol:
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on June 17, 2006, 07:26:17 pm
Thank you for the autotools tip.  Do you know if autoconf can be made to include architecture specific optimizations when configureing?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: TheTuxKeeper on June 17, 2006, 08:56:48 pm
Thank you for the autotools tip.  Do you know if autoconf can be made to include architecture specific optimizations when configureing?
I have only little experience with autotools (read few parts of this "Autotools Tutorial" eBook (http://www-src.lip6.fr/homepages/Alexandre.Duret-Lutz/autotools.html)).
But take a look at acinclude.m4. There is a target and a platform check ( the CODEBLOCKS_GET_PLATFORM or the CODEBLOCKS_SETUP_FOR_TARGET part at the beginning). The architecture is the first part of the target string ( target = $CPU-$VENDOR-$OS ).
In line 188 of acinclude.m4 is also a platform check (for the xp-manifest plugin).
AFAICS it can be done with bash/sh ifs and cases ;)

Hope these hints can help you. :)
I can't give you a more exactly answer because I don't know these things, I'm learning them by reading the existing code (I didn't even know what I wrote above when I read your post :mrgreen:).
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on June 19, 2006, 03:50:04 pm
I haven't had a chance to use this, but I think found a good profiler to use with CB.  Gprog/sprof are pretty hard to use because of all the shared libraries CB uses.  Sysprof, which is a kernel module and application, let you profile the any application in the system.  Hope this helps the CB team.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Jabber on August 14, 2006, 12:24:32 pm
Hi,

I'm having the same problems on Debian Etch (=Testing). I tested the current SVN against self-compiled wxGTK 2.6.2 ANSI builds and wxGTK 2.6.3 Unicode builds; both show the awfully slow editor behaviour. Scite isn't blazing fast, but compared to C::B not slow at all.
Is there anything I can do to trace this down? I've got no experience with profiling and would need some detailed instructions...

Jabber
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on August 14, 2006, 11:40:00 pm
I gave it a try with sysprof and most of the time was spent acutally in pango.  I should try it again and compare to scite to see what the difference is.  Most of the time there is noticeable lag, its not the kind where you type faster than text appears, but its still there.

Sysprof is was pretty easy to install in Ubuntu.  You should have it in the debian repositories as well.

I would be interested to hear if Mandrav has the problem since he developes on Ubuntu.  Maybe his machine is fast enough that it doesn't max out the CPU.

Quick question Jabber, are you using custom font colors?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Jabber on August 15, 2006, 10:30:27 pm
Quick question Jabber, are you using custom font colors?

No, I'm not.

If I got some time left on the weekend I'll give sysprof a shot.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Jabber on August 19, 2006, 12:39:18 pm
Good news, everyone  :D

I installed sysprof and was ready to start profiling when I noticed the slow editor problems no longer were there. I profiled anyway and found a substantial time was spend in libcairo for font rendering. A new version of libcairo (1.2.2) entered Etch yesterday (or was it the day before?), so I suspect something was fixed upstream by the cairo devs.
So, anyone with slowness problems should try to update libcairo to a version >=1.2.2.

Jabber
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on August 21, 2006, 02:17:40 am
Have you downgraded libcairo and tried again, just to double check.  I will try this when I get a chance, I guess it will fininally give a reason for me to learn how to build a source package on Ubuntu.

EDIT: It turns out 1.2.2 is in the next version of Ubuntu, Edgy Eft, but I don't want to run something as unstable as that on my laptop which can't have its drivers breaking all the time.  So if I build another desktop I will give it a try on there.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Jabber on August 22, 2006, 06:40:17 pm
Lots of packages depend on the latest version of libcairo, so I'll restrain from downgrading -- I don't want to break my main desktop...

I'm not sure if it was just libcairo's fault, because others like you use older versions without having the slowness problem. Anyway, it was solved for me by upgrading, so hopefully it helps others, too.

Jabber
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 28, 2006, 10:49:27 am
Hello again,
For the whole summer I dropped my desktop pc and grabbed my laptop where I have also installed ubuntu with the same almost configuration. I thought that this "bug" was fixed because everything worked perfect on it. Now that I am back, I tried latest C::B on my desktop pc, and I understand that this "bug" appears only on the desktop pc (which is 2 times faster than laptop).

All I am saying is that this is not "an-all-ubuntu" bug, but I cannot understand what's the prob with those individuals pc's.
maybe wrong Xorg conf?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: mandrav on August 28, 2006, 11:24:37 am
Maybe the graphics card driver? Can you try changing X to use the framebuffer driver on your desktop PC and see if it still crashes?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 05:58:51 am
1st of all, It's not a crash!

It is just slow, when I type fast the characters appear five-five and not one-by-one. When I move the mouse around inside the text editor I get 100% cpu usage.

I did the following:
 * reconfigured xorg to get back the default xorg.conf of ubuntu
  Used the "nv" driver and retarted X bla bla...
  Results: the same exactly promblem
 * Tried to use the "fbdev" driver (You told me something about the framebuffer driver, this you mean?)
  Couldn't start x with various of problems that I cannot solve
 * restarted X with my usual xorg.conf and DISABLE everyplugin (even compiler)
  I opened a c++ file with some code and tried to write...
  Results: the same
 * (GNOME:) I went at system->preferences->fonts and disabled hinting and smoothing of fonts (really ugly but font rendering is way faster)
  Results: C::B was exactly the same slow when typing scrolling etc!

I don't know what's the prob, I am now preparing to build a custom kernel to see if thing changed. On the other hand I am looking around at ubuntu forums as well to find a solution.

(I am here to do whetever tests you want ;) )
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: mandrav on August 29, 2006, 08:36:12 am
Quote
1st of all, It's not a crash!

Yes, sorry I mixed it with another problem mentioned the same day.
Did you read this post (http://forums.codeblocks.org/index.php?topic=2869.msg30439#msg30439) (maybe it helps)?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 09:18:35 am
(If you mean to try profiling..)
Yes I read it... but I cant spent time now for that, I just want to make it work to finish a couple of exercises I have to do for my university. (dipli eksetastiki klp.  sry)

(If you mean to upgrade to >libcairo-1.2.2) I must do many tricky thinks to stay at dapper or upgrade at edgy. Both ways sound very unstable for my main pc :S

Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 09:54:57 am
Tried something more:

I checked out the svn tree and compiled it using:
CXXFLAGS="-O3 -march=athlon-xp -pipe"

removed deb package and did make install bla bla
Result: THE SAME, maybe a very very small differnce but it still slow

Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: mandrav on August 29, 2006, 10:36:29 am
You have an NVidia, right?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 03:13:04 pm
Athlon XP 2.2+/Via chipset/ 1GB ram /Nvidia FX 5700 128mb
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 04:27:10 pm
OK I installed sysprof (It was really easy to use it, as I was afraid :p)
I save 2 logs, one when moving mouse around, and one when I was typing text. I attached them for review by the experts (You need sysprof to open them in a human readable way)

[attachment deleted by admin]
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 04:36:24 pm
Sry for the many small post... I am not doing it to increase my Posts counter :p
It is because I see something more and more that I think I must post.


Here is another sysprof log when I scroll text up and down with mouse wheel, which is very laggy.
If I move the scroll wheel fast 5 times up-down I need 15seconds to finish moving!

[attachment deleted by admin]
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sethjackson on August 29, 2006, 06:57:05 pm
Are you using the proprietary nVidia driver???

I have OpenBSD + X.Org 6.9 + GeForce2 MX/MX 400, and it works fine. :)
I have't compiled C::B on it yet because the wx version is at 2.4.2 for OpenBSD.....
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 29, 2006, 10:14:40 pm
Everything else works fine for my pc... at least that it looks like.

Are you using the proprietary nVidia driver???
Yes I am running on proprietary drivers 8762

part of my /var/log/Xorg.0.log
Code
sque@ubuntu:~$ cat /var/log/Xorg.0.log | grep NVIDIA
(**) |   |-->Device "NVIDIA Corporation NV36 [GeForce FX 5700]"
(II) Module glx: vendor="NVIDIA Corporation"
(II) Module nvidia: vendor="NVIDIA Corporation"
(II) NVIDIA X Driver  1.0-8762  Mon May 15 13:09:21 PDT 2006
(II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
(--) Chipset NVIDIA GPU found
(**) NVIDIA(0): Depth 24, (--) framebuffer bpp 32
(==) NVIDIA(0): RGB weight 888
(==) NVIDIA(0): Default visual is TrueColor
(==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
(**) NVIDIA(0): Option "RenderAccel" "true"
(**) NVIDIA(0): Enabling RENDER acceleration
(II) NVIDIA(0): NVIDIA GPU GeForce FX 5700 at PCI:1:0:0
(--) NVIDIA(0): VideoRAM: 131072 kBytes
(--) NVIDIA(0): VideoBIOS: 04.36.20.19.06
(II) NVIDIA(0): Detected AGP rate: 8X
(--) NVIDIA(0): Interlaced video modes are supported on this GPU
(--) NVIDIA(0): Connected display device(s) on GeForce FX 5700 at PCI:1:0:0:
(--) NVIDIA(0):     Samsung SyncMaster (CRT-1)
(--) NVIDIA(0): Samsung SyncMaster (CRT-1): 400.0 MHz maximum pixel clock
(II) NVIDIA(0): Assigned Display Device: CRT-1
(II) NVIDIA(0): Validated modes:
(II) NVIDIA(0):     "1280x1024"
(II) NVIDIA(0):     "1024x768"
(II) NVIDIA(0):     "800x600"
(II) NVIDIA(0):     "640x480"
(II) NVIDIA(0): Virtual screen size determined to be 1280 x 1024
(--) NVIDIA(0): DPI set to (95, 96); computed from "UseEdidDpi" X config option
(II) NVIDIA(0): Setting mode "1280x1024"
(II) NVIDIA(0): NVIDIA 3D Acceleration Architecture Initialized
(II) NVIDIA(0): Using the NVIDIA 2D acceleration architecture
(==) NVIDIA(0): Backing store disabled
(==) NVIDIA(0): Silken mouse enabled
(**) NVIDIA(0): DPMS enabled
(II) XINPUT: Adding extended input device "NVIDIA Event Handler" (type: Other)

glxgears works with 5000 fps. I can run Xgl with no problem of speed and everything works perfect... I can see video...
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on August 29, 2006, 11:59:21 pm
I am not at my Linux machine right now, but lets not just guess its graphics driver.  I use ATI and I do have the problem.  I think the best thing would be to do as sque has already started, compare sysprof profiles of the same activity.  For example scrolling through a very long project file (everyone would do the same one from the CB project), or just continuously typing for for 1 to 2 minutes.  Then we can see where the people with the slowdown spend there time.

I found the biggest chunck of time was spent in pango invoked by scintilla.  Sque, I suggest you just give sysprof a try its not to hard to figure out how it works and would probably a good learning experience.  Sysprof shows you a tree view of each running process and how much of its time was spent in each branch (each branch being a function with its subbranches being the functions it calls).  You have to find the one which is codeblocks and go from there.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sethjackson on August 30, 2006, 03:29:37 am
Has anyone tried SciTE on a *nix box, and compared it to C::B on the same *nix box?
I may try to compile Scintilla and SciTE soon to see if it is slow....
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: takeshimiya on August 30, 2006, 04:12:05 am
Has anyone tried SciTE on a *nix box, and compared it to C::B on the same *nix box?
I may try to compile Scintilla and SciTE soon to see if it is slow....
And let's not forget wyoEditor too (since it may be a wxScintilla issue).

http://wyoguide.sourceforge.net/downloads.html
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on August 30, 2006, 07:29:18 am
Has anyone tried SciTE on a *nix box, and compared it to C::B on the same *nix box?
I may try to compile Scintilla and SciTE soon to see if it is slow....

I tried Scite and there are no problems like this. Typing-displaying character is instant, cpu-usage is low, scrolling etc are also acting normally. The only slowiness I saw on scite is when I tried to paste 1000 lines of C++ code from codeblocks to scite it took 5 seconds for scite to become responsible (and cpu usage went 100%)


Sque, I suggest you just give sysprof a try its not to hard to figure out how it works and would probably a good learning experience.  Sysprof shows you a tree view of each running process and how much of its time was spent in each branch (each branch being a function with its subbranches being the functions it calls).  You have to find the one which is codeblocks and go from there.

I already gave a try on Sysprof and as you can see on previous posts there are attachments of its log. What I can't understand is what kind of value is the number that displays. Time? calls? . If I assume that this is some type of time It seems that there is an abuse from libgdk-x11..., libpango and libcairo with libpango getting the leadership (4.12 self) after that libcairo. Inside codeblocks the only thing that takes time is DoPaint. So the problem is from DoPaint and child calls.


So! I made some changes on codeblocks source on the ScintillaWX::DoPaint to get some times
Code
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
    paintc++;
    clock_t startClock, endClock ;
struct timeval now, start;

// Start timers
startClock = clock();
gettimeofday(&start, NULL);



    printf("DoPaint(%d)",paintc);
    paintState = painting;
    Surface* surfaceWindow = Surface::Allocate();
    surfaceWindow->Init(dc, wMain.GetID());
    rcPaint = PRectangleFromwxRect(rect);
    PRectangle rcClient = GetClientRectangle();
    paintingAllText = rcPaint.Contains(rcClient);

    dc->BeginDrawing();
    ClipChildren(*dc, rcPaint);
    Paint(surfaceWindow, rcPaint);

    delete surfaceWindow;
    if (paintState == paintAbandoned) {
        // Painting area was insufficient to cover new styling or brace
        // highlight positions
        FullPaint();
    }
    paintState = notPainting;
    dc->EndDrawing();

    endClock = clock();
gettimeofday(&now, NULL);
    printf("Time:CPU(%5.3f ms), REAL(%5.3f)\n",
        ((float)(endClock-startClock) / ((float)CLOCKS_PER_SEC/1000.0)),
        (float)((float)now.tv_sec-start.tv_sec)*1000.0+((float)now.tv_usec-start.tv_usec)/1000.0
        );
}


Here is the output on the console when
  * Tapping the right arrow 5 times to move at a new location
   
Code
DoPaint(1724)Time:CPU(120.000 ms), REAL(232.222)
DoPaint(1725)Time:CPU(0.000 ms), REAL(4.103)
DoPaint(1726)Time:CPU(110.000 ms), REAL(217.649)
DoPaint(1727)Time:CPU(0.000 ms), REAL(4.151)
DoPaint(1728)Time:CPU(100.000 ms), REAL(243.462)
DoPaint(1729)Time:CPU(0.000 ms), REAL(8.608)
DoPaint(1730)Time:CPU(100.000 ms), REAL(228.856)
DoPaint(1731)Time:CPU(0.000 ms), REAL(3.834)
DoPaint(1732)Time:CPU(150.000 ms), REAL(285.846)

   * Writting the word: "12345" veryyy fast (in less than a second)
Code
DoPaint(1872)Time:CPU(0.000 ms), REAL(2.006)
DoPaint(1873)Time:CPU(120.000 ms), REAL(193.427)
DoPaint(1874)Time:CPU(0.000 ms), REAL(2.551)
DoPaint(1875)Time:CPU(90.000 ms), REAL(185.037)
DoPaint(1876)Time:CPU(0.000 ms), REAL(2.171)
DoPaint(1877)Time:CPU(90.000 ms), REAL(205.687)
DoPaint(1878)Time:CPU(0.000 ms), REAL(2.036)
DoPaint(1879)Time:CPU(100.000 ms), REAL(189.700)
DoPaint(1880)Time:CPU(0.000 ms), REAL(12.403)
DoPaint(1881)Time:CPU(90.000 ms), REAL(191.264)
     So it needs about 193+185+205+189+191=963 ms to render it which is maybe more than I tried to type it

The wierd (at least for me) is that CPU times are greatly different than the real times. What I suspect is that the problem is on somekind of mutexs that consum time to lock-unlock. I checked on the sysprof log and the only mutexes that I found are inside libcairo. But... why only on some kind of PCs?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: eranif on September 06, 2006, 11:32:47 pm
Hi,
Did anyone come up with any solution for this problem?

I having the same problem on fedora core 4 & 5

Unistalled them, installed Ubuntu Dapper (which I seem to like more then FC :D), problem still there.

The only different is that I am having the problem with my demo application that I wrote for the CodeCompletion alternative (which uses scintilla).
The typing is *very* slow, if you type more than 5 chars, the cursor disappear ... for a second or two  :lol:
Holding the enter key down, will "freeze" the application until you leave it and then it will insert all the newlines.

I downloaded SciTE, built it, ran it - works perfect.

Any suggestions?
Maybe it is related to my processor which is 64bit?
or my video card ATI?

Eran


Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on September 24, 2006, 01:12:04 am
Plz some focus on this problem... some ideas, some suggestions, Ask for any test.
YOU ARE GOING AGAINST OUR RIGHT TO WORK WITH C::B :D

Ok, I just want to say that I am using ubuntu, I have no other problem (maybe I found my best linux distro), and because of C::B some small ideas of reinstalling gentoo pop-up in my head (and I DONT want!). I am working on a project and every day that a new file comes, more lines appear, the problem grows and grows. Believe it getting in your nervs when you want to scroll up or down to see what it is written and you think it twice before doing this.

So, what I ask, is some focus on this problem. Although I understand that you have no idea why on the hell this happens and you cannot reproduce it, we (as I see, I am not only one) can give you plenty of info of our system or whatever you want, we can make (almost)any test. If It could be possible, I would sent you my box for examination/experiments  :P But I wouldn't say no for a VNC connection to make whatever tests you want. I think it is a critical BUG, it makes C::B totaly unusable!
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on September 24, 2006, 06:18:04 am
I seem to have the problem on and off.  It was problem for me in the past but not so much now (possible driver issue?).  Eranif can you post you exact system specs and the result of the "glxinfo" command?  CB definitely seems faster when I have the fglrx driver installed vs. the standard open source ATI one.  I run 32 bit Ubuntu.

sque, if the bug is affecting you so much I suggest you grab an Ubuntu live CD, and a precompiled version of codeblocks that has the issue and try it on as many computers as you can.  Maybe you can find some kind of hardware + software that causes the issue.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: eranif on September 24, 2006, 10:42:19 am
I forgot to post it, but I already solved my problem. My problem was excessive calling to TextWidth() function which caused huge performance degradation.
 
This slowed the typing in the editor only Linux machines ( I tried it on FC4/5 and Ubuntu) but did not cause any slow effects on windows.

This was called on OnChange notification

Eran
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Pecan on September 24, 2006, 01:48:11 pm
I forgot to post it, but I already solved my problem. My problem was excessive calling to TextWidth() function which caused huge performance degradation.
 
This slowed the typing in the editor only Linux machines ( I tried it on FC4/5 and Ubuntu) but did not cause any slow effects on windows.

This was called on OnChange notification

Eran


Where, what Onchange. What TextWidth()? Scintilla, Main, SDK, what Line?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: eranif on September 24, 2006, 03:45:55 pm
I forgot to post it, but I already solved my problem. My problem was excessive calling to TextWidth() function which caused huge performance degradation.
 
This slowed the typing in the editor only Linux machines ( I tried it on FC4/5 and Ubuntu) but did not cause any slow effects on windows.

This was called on OnChange notification

Eran



Where, what Onchange. What TextWidth()? Scintilla, Main, SDK, what Line?

Hi,

On my first post, I complained of having similar problem (of very slow performance) on linux using other application that uses scintilla.

the problematic function, was a function named TextWidth(), which is a wrapper for wxDC::GetTextExtent.

This function, uses *alot* of CPU on Linux (and is hardly noticed on windows), and it was called alot on my application.

Once this function is removed from my application code, the problem was gone.
I wonder whether this function is the cause of the other problem.
Eran

Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: troels on September 24, 2006, 04:11:51 pm
This function, uses *alot* of CPU on Linux (and is hardly noticed on windows), and it was called alot on my application.
Probably related to this:
http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/77308
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on September 25, 2006, 01:16:13 am
sque, if the bug is affecting you so much I suggest you grab an Ubuntu live CD, and a precompiled version of codeblocks that has the issue and try it on as many computers as you can.  Maybe you can find some kind of hardware + software that causes the issue.

First of all the versions that I have tested (the last 6 months) had the same prob. Never tried the RC2
Otherwise I would stick with a working one, and I wouldn't whining ;)

That was a good idea with live cd, I go forward to download one (But only breezy ubuntu comes in a live cd). Anyway, I ll come with more results.

As for the TextWidth mystery... is it worth to look at? Should I try something?
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: Game_Ender on September 25, 2006, 05:34:48 am
You are mistaken and probably thrown off by the fact that there is no listing for a "Live CD" for Dapper.  The standard "Desktop" CD is actually a live CD.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on September 26, 2006, 02:00:33 am
You are mistaken and probably thrown off by the fact that there is no listing for a "Live CD" for Dapper.  The standard "Desktop" CD is actually a live CD.

Bingo you were right. I had a beta cd of Dapper and wasn't live cd. the 6.06.1 is live cd too.
BUT! I am so embaresed :oops: I booted from the live cd and codeblocks works just fine :( It's time for me to format... (But all the other applications works exactly the same way).

I think i deserv all of you a "sorry", but after the format :P
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: thomas on September 26, 2006, 11:22:15 am
As for the TextWidth mystery... is it worth to look at? Should I try something?
If that's a known issue (which it is, apparently), it may be worth looking into wxFlatNotebook, too.
The reasoning behind this is that SciTE seems to work Ok for you, and wxFlatNoteBook is the most prominent difference between Code::Blocks and SciTE editors, so it might be worth having a look at that, too. In any case, it will be easier to fix than the many wxScintilla occurrences.

On my machine, wxPageContainerBase::OnPaint is called an entire six times whenever I do anything except typing with an editor. No idea why it happens, but 6 sounds like "5 times too often" to me. It may of course be an issue of the wxWidgets message queue, too (and as such may be different for you).
wxPageContainerBase::OnPaint calls GetTextExtent ( == TextWidth) twice every time (once on static text, and once on the tab title, both of which could as well go into a static variable). The same constants are recalculated over and over again in several places (when fitting to screen or scrolling). Normally, I'd say it doesn't matter, but if that function is really so slow, one might want to rethink this approach.

On my machine, the abysmal performance problem is not present, so I cannot verify whether all this matters at all.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: sque on September 26, 2006, 02:43:35 pm
After a clean fresh install of ubuntu (the previous has passed from many stages Brezy -> Dapper beta -> dapper final), there is a significant difference, CB is now workable, but occasionally I get the same wierd slowniness (for a few minutes).

Before formating, tried to eliminate some calls to the TextWidth, but when I tried to run CB (with the nvidia driver) my X crashed! With the "nv" driver it worked, and there was a good speed boost, but many artifacts. What I think but I it is difficult to implement as I am not familiar with the internals, the text's width should be cached in some way.
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: eranif on September 26, 2006, 02:46:54 pm
six times? sounds alot.. I can look into it. Does it occures when you are moving the mouse over the tab drawing area? if so I think I know where the problem is.

However, the problem is occuring when typing in the editor, which according to your findings, is the only case where wxflatnotebook does not do excessive painting)

Not to mention, that I tested wxFlatnotebook with scintilla on Ubuntu and it works perfectly (the only time it does not, is when the TextWidth is called inside scintilla ... )

Still, I will have a look into the six drawing issue.
Btw, how did you measure it? did you add debug info? put a break point? etc.

Eran

Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: thomas on September 26, 2006, 03:57:43 pm
Does it occures when you are moving the mouse over the tab drawing area? if so I think I know where the problem is.
Not when moving, but when clicking on it, when giving back focus to a pane, when clicking onto an editor pane that already has the focus for the first time (does not happen the second time), when scrolling tabs, opening editors, etc.

Quote
Btw, how did you measure it? did you add debug info? put a break point? etc.
Hahaha, too much trouble... I've simply put a printf("."); into that function and built Code::Blocks as console application. :)
What I get when anything "happens" to a tab is "......"

I came upon it at all because I did a global file search on GetTextExtent and found that it is indeed used in many places inside wxFNB (once inside a loop, too).

Just out of curiosity, I put in this printf into the draw function and saw that it was indeed called surprisingly often.
Since a tab's title is set via an accessor function, it should be trivial to do without all these and make the width a member function that is updated only when needed. GetTextExtent(_T("Tp"), ...) returns a constant so this could be trivially optimised out, too. I guess then it doesn't matter much how often a function is called any more.


BTW, similar things seem to happen inside Scintilla, for example it recalculates the line number width each time is is drawn (which leads to the question: Does turning line numbers off improve performance?), and it recalculates the font's (constant) ascent value when showing tooltips each time, too. Tooltips aren't shown a hundred times per second, but if it can take hundreds of milliseconds for GetTextExtent to finish, it may be worthwile to cache this too...
Unluckily, global search following the many alias functions inside wxScintilla reveals that it recalculates a lot of text widths in many places (above all, formatting text... :(), so rather than fixing one or two hotspots, the only feasible way of fixing things may be to find a GetTextExtent replacement.

I don't know how it is exactly implemented, however from the documentation, it almost looks like cairo_scaled_font_text_extents() is really the same as cairo_show_text(), except for suppressing the actual output.
As a proposed solution, one could call cairo_scaled_font_glyph_extents() once (once every time the editor font is changed), and on request sum up the x_advance values of all characters in a string (using x_bearing for the last character). Summing up one or two dozen doubles from an array should not take any significant amount of time at all.
Anyone here have a deep insight into Cairo and willing to give it a shot? ;)
Title: Re: Slow perfomance on linux (Ubuntu Dapper)
Post by: eranif on September 26, 2006, 05:16:21 pm
I am currently updating wxFlatNotebook to work with renderers, so it is a a good opertunity for some maintenance, the OnPaint function is getting too big to handle (not to mention that it is a correct design to work with abstaract renderer, this way adding new styles is *much* easier)

I will try to remove redundant text calculations where I can.
Eran