QtCreator performance on Windows - c++

I've finally managed to run the QtCreator debugger on Windows after struggling with the Comodo Firewall incompatibilities.
I was hoping to switch from an older version of Qt and Visual C++ to the newest version of Qt and QtCreator, but the debugger performance is atrocious.
I have created a simple GUI with one window that does nothing else but display the window. After starting up QtCreator takes ~60MB RAM (Private bytes in Sysinternals process explorer).
When I start debugging, GDB is using 180MB. I start examining the main window pointer and it jumps to 313. Every time I try to inspect something, one of the cores jumps to 100% use and I have to wait for a few seconds for the information to show. This is just a toy program and I'm afraid that the real program that I want to switch will be much worse.
Is this kind of performance normal for MinGW? Would changing to the latest MinGW release improve things?
Visual C++ IDE + debugger + real-world program takes just close to 100MB of RAM and examining local variables is instantaneous.

Yesterday I built a copy of the Qt 4.5.2 libraries using MSVC 2008 and am using the QtCreator 1.2 MS CDB (Microsoft Console Debugger) support. It seems much faster than gdb. Building Qt for MSVC takes a few hours, but it might be worth trying.
Also, that means smaller Qt DLLs and EXEs as the MS compiler/linker is much better at removing unused code. Some of the Qt DLLs are less than half the size of their MinGW equivalents. Rumour has it that the C++ code the MS compiler generates is faster too.

I had to work with QtCreator a month ago. It's performance is awful, after 30 minutes of working with him, it will start to respond very slowly to everything. Maybe it's because it's still at the beginning.

Related

C++ program runs much slower on Windows vs Linux when doing file operations?

I use an open source project called ChatScript for natural language processing app development.
When you execute a build operation with ChatScript, it scans all the script files that comprise your chat-bot. In my case, that's hundreds of files. This process takes nearly 30 times longer on Windows 8.1 than it does on Ubuntu 16.04. Therefore I do use Linux for much of my work, but there is a part of my work that I have to do on Windows because of certain associated tools, so I would like to modify the code base so that Windows ChatScript compiles are as fast as on Linux.
Can anyone think of a reason the code would run so much slower on Windows vs. Linux? Are there some C++ file operation codes (read/write/etc.) that are known to be much slower on Windows compared to Linux due to variances in the C++ run-time libraries running on each platform?
By "code running slow" in your last paragraph I'm assuming from context that you're referring to the compiler???
I've encountered frequently and consistently over many years a general, significant performance difference between linux and Windows in disk I/O. NTFS (Windows file system) and the linux file systems handle the situation of lots of files differently, and linux is always quicker in the circumstances I've been in.
You may benefit from some of the pointers in answers to questions like How do I get Windows to go as fast as Linux for compiling C++?, like defragmenting your windows drive, and checking how the compiler optimisations are configured; some of them can slow down the compiler (although an aggressive compiler optimisation setting can slow the compiler down, you produce a faster executable at the end, but that might be something you switch to after most of your development is done).
But doing all those things for me has never got the Windows compile to be quicker than on linux using equivalent disk hardware, not once. If your code is on the one disk and sourced for both compiles, any improvement you'll see in the Windows build (e.g. because the code's put on an SSD) will likely be replicated in an improvement in the linux build as well.
Just to confirm I found the same thing. Ran the same Chatscript scripts on an average Mac and on a fast XPS 15. The Mac compiled the code 30-50 times faster than Windows. What's weird is ChatScript was originally developed for Windows. I also have not worked out why such a gigantic lag, in spite of the Windows PC hardware being much more powerful than the Mac running the script.
So I have come across both an explanation and a (partial) solution. There are two areas of lag in Windows compared to Linux:
Networking behaviour. According to the creator of ChatScript, Bruce
Wilcox, the Windows server code is worse under the hood, and is also
implemented worse in ChatScript for Windows vs ChatScript for Linux.
The lag here is however minor.
Build times. This is where building the bot in Linux takes 10-20
seconds and on Windows 4-5 minutes. Turns out that the reason is the
antivirus:
"Curious about the huge discrepancy, one of our hardware engineers
did some profiling and found the real culprit to be the anti-virus
software. Disabling the real-time virus protection feature of
Windows Defender brought the 4 minutes down to 14 seconds! Even
keeping Windows Defender active, but excluding the
ChatScript-master folder solved much of the slowdown problem,
resulting in about 20 s for :build 0 to complete."
(https://www.chatbots.org/ai_zone/viewthread/3575/)
So for OP, if you exclude CS from Windows Defender, or switch it off, the build differential will largely disappear.

Same executable, different filename changes performance

I have an executable (neural network simulation software) developed in C++ and wxWidgets, compiled in Visual Studio 2010. On my development machine (Windows 7 64bit) it was running very slowly, taking 130 seconds instead of 14 seconds for the same run. I finally discovered that it works fine if I just changed the filename of the exe. To hunt for the cause I've turned off antivirus (Microsoft Security Essentials, searched the registry and event logs, but found nothing. Doesn't matter if it's compiled with wxWidgets DLL or static library, 32bit or 64bit.
What could possibly be the problem? Processor affinity and priority is all normal. Only clue is that the process also uses more memory (130meg instead of 90meg).

Code::Blocks debugger painfully slow on Kubuntu

I have Kubuntu 14.10 and 15.04 installed on my four computers, all having different hardware (the oldest machine was assembbled in 2007 and the newest just a month ago. I have both 32- and 64-bit OSs installed. The amount of RAM varies from 4 to 32 GB). I have been using Code::Blocks on them for a few months, and I experience the same problem on all 4 machines: integrated debugger is painfully slow when debugging a C++ program.
After the debugger stops at a breakpoint, it takes 10 seconds to 5 minutes to step through a single line of code. And while the debugger is performing a step, one core of my CPU is loaded by GDB by 100%. And often trying to step through a line of code hangs forever. After that I have to kill GDB and the process that has been debugged.
Some time ago I updated GDB to version 7.9 (from 7.8) but this did not fix the problem. And I have no slowdown when debugging with GDB from command line, so I suspect that the problem is in the Code::Blocks debugger plugin.
I saw many complaints regarding similar problems, some of which were allegedly caused by outdated libc6-dbg (more exactly, by the fact that debug symbols were not shipped with Ubuntu and other Debian-based distributions), but reinstalling libc6-dbg did not help either.
I am afraid that after a day or two of trying to fix this problem I will give up and will switch to Eclipse or some other IDE. It looks like Code::Blocks and its debugger plugin have not been updated for a couple of years (at least, their Linux versions). So maybe I should not use Code::Blocks at all because its future is not clear (while Eclipse is likely to be in service for long time).
I wonder if anybody else experiences this problem and whether there are solutions. Overall Code::Blocks IDE looks decent and rather convenient, but this debugger problem prevents from using it for purposes other than writing code and compiling.
An update:
I ended up installing Eclipse for C++ (Luna release). It took some time to learn how to use it. It is slow, buggy, glitchy and uses a lot of RAM, but it at least allows me to debug my applications in IDE. Now I am 100% sure that the problem is in Code::Blocks debugger plugin.
I also tried NetBeans, and seems to work fine, but it is even slower than Eclipse and looks really ugly. So I am going to stick with Eclipse for now because no one seems to be willing to fix the debugger plugin in Code::Blocks.
The problem turned out to be with stepping through lines that declare uninitialized std::string objects. A similar (or the same) problem is described here:
https://sourceware.org/bugzilla/show_bug.cgi?id=12555
The probleb with debugging in Code::Blocks was suddenly fixed when I followed these instructions:
http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_inspect_the_contents_of_STL_containers.3F
on how to enable pretty-printing in Eclipse CDT.
I still need to follow these instructions on my other machines to make sure they fix the problem.
You can try and turn off CodeBlock pretty-printing: Settings->Debugger->Default->Enable Watch Scripts = Unchecked
(Source)

Why is gdb so slow in Windows?

I recently noticed that running a program inside gdb in windows makes it a lot slower, and I want to know why.
Here's an example:
It is a pure C++03 project, compiled with mingw32 (gcc 4.8.1, 32 bits).
It is statically linked against libstdc++ and libgcc, no other lib is used.
It is a cpu and memory intensive non-parallel process (a mesh edition operation, lots of news and deletes and queries to data structures involved).
The problem is not start-up time, the whole process is painfully slow.
Debug build (-O0 -g2) runs in 8 secs outside gdb, but in 140 secs within gdb.
Tested from command line, just launching gdb and just typing "run" (no breakpoints defined).
I also tested a release build (optimized, and without debugging information), and it is still much slower inside gdb (3 secs vs 140 secs; yes, it takes the same time as the not optimized version inside gdb).
Tested with gdb 7.5 and 7.6 from mingw32 project, and with a gdb 7.8 compiled by me (all of them without python support).
I usually develop on a GNU/Linux box, and there I can't notice speed differences between running with or withoud gdb.
I want to know what is gdb doing that is making it run so slowly. I have some basic understanding of how a debugger works, but I cannot figure out what is it doing here, and googling didn't helped me this time.
I've finally found the problem, thanks to greatwolf for asking me to test other debuggers. Ollydbg takes the same time as gdb, so it's not a gdb problem, its a Windows problem. This tip changed my search criteria and then I've found this article* that explains the problem very well and gives a really simple solution: define an environment varible _NO_DEBUG_HEAP to 1. This will disable the use of a special heap system windows provides and c++ programs use.
* Here's the link: http://preshing.com/20110717/the-windows-heap-is-slow-when-launched-from-the-debugger/
I once had issues with gdb being incredibly slow and I remember disabling nls (native language support, i.e. the translations of all the messages) would remedy this.
The configure time option is --disable-nls. I might have just been mistaken as to what is the true cause, but it's worth a shot for you anyways.
My bug report from back then is here, although the conclusion there would be that I was mistaken. If you can provide further insight into this, that would be great!

Qt 5.1.0 on Windows using minGW 4.8 taking a really long time to debug

I have downloaded and installed the Qt 5.1.0 for Windows 32-bit (MinGW 4.8) from the qt-project downloads page. I have run the installer, and am able to compile and run applications using these libraries and the minGW 4.8 32-bit toolhchain.
However, I have a large application, and when I try to debug it (using the gdb bundled with the minGW toolchain), it takes an insane amount of time to start running, and any interaction with the application takes a long time to complete. Not an annoying amount of time, but an unusable amount of time. Has anyone else had this problem and are there any solutions?
In case this helps, I get lots of output when debugging like this:
Temporarily disabling breakpoints for unloaded shared library "C:\Qt\Qt5.1.0\5.1.0\mingw48_32\plugins\somefolder\somelib.dll"
There is a gdb bug that was introduced at some point between 7.4 and 7.5, which makes it much slower. When debugging QObject classes, the slower becomes awfully slow.
By disabling debugging helper, you improve it, but then you miss a lot of precious information in the Local Variables and Expressions. For instance, you cannot display nicely the contents of QLists, etc...
It seems that either:
buidling gdb from the CVS or
using an older gdb (7.4.1)
solves the issue.
Qt creator has "attempt quick start" in its gdb options. It helps a LOT.
Or you can switch to using MSVC compiler on Windows. That also switches your debugging to CDB instead of GDB and bypasses the problem entirely. You can just install MSVC compiler and plug it into QtCreator instead of mingw if you don't like MS IDE.
P.S. This also gives you readable core dumps which is a godsend.
See the comments on Zeks' answer. There he explains that switching from the MinGW toolchain to the Microsoft toolchain (compiler, debugger) solves the problem completely. Fortunately, Qt Creator supports the Microsoft toolchain so you don't need to switch IDEs.
After I did that, debugger launch time is now 4sec, and on app crash it there is zero delay. It also sped up builds a lot.
For reference, I've described how I've set up my system here.
I have managed to improve the debugging speed significantly after changing several settings:
Made sure the compiler is gcc.exe and not g++.exe in the Qt5.1.0\Tools\mingw48_32\bin folder
Unchecked Use Debugging Helper in the Tools->Options->Debugger->Locals & Expressions menu
Unchecked Stop when qWarning() is called and Stop when qFatal() is called