String related slow with debugger attached Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

String related slow with debugger attached

Post by gul_garak »

We came across an odd issue. I did some searches and found some references, but nothing that explained it or how to work around it. Not sure if I should post in this forum or the Compiler/IDE one.

Boiling it down, it seems that anything to do with wxString usage, including parsing folders, wxXMLDocument, etc. slows down by a couple of orders of magnitude when the debugger is attached. Our IDE is Visual Studio 2012.

This isn't a release vs debug build issue, the debug build runs at normal speed when you launch outside the debugger.

Also, we are porting a large app that previously used MFC's CString's so it seems something related to the wxWidgets implementation of strings and the debugger in particular.

Does anyone know if there is something we can turn off in the debugger? Or something that can be switch off in the debug build of wxWidgets? The wxXMLDocument slow down in particular makes it very hard to run our app with the debugger attached.

Thank you!

- Alejandro
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: String related slow with debugger attached

Post by doublemax »

I'm working with Visual Studio almost exclusively since VS2003 and never had this issue, so i can't give any solution.

Things i would try:
Check the watch window, check for conditional breakpoints, etc.
Build and run on a different PC, maybe the VS installation is just messed up somehow (which happens quite often).
On the wxWidgets side: Depending on whether your build uses STL strings or wxWidgets' own string implementation, try the other one.
Use the source, Luke!
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Re: String related slow with debugger attached

Post by gul_garak »

doublemax wrote:I'm working with Visual Studio almost exclusively since VS2003 and never had this issue, so i can't give any solution.

Things i would try:
Check the watch window, check for conditional breakpoints, etc.
Build and run on a different PC, maybe the VS installation is just messed up somehow (which happens quite often).
On the wxWidgets side: Depending on whether your build uses STL strings or wxWidgets' own string implementation, try the other one.
You won't notice unless you are doing a lot with strings. The wxXMLDocumment is the one that makes it such a problem for us, the other ones aren't as critical. But you can also reproduce it with a simple benchmark app.

Breakpoints, etc. wasn't the issue, and it's happening for everyone in the team (so that's several computers if you add PCs and laptops). I'll investigate changing string implementation and report back.

Thank you!

- Alejandro
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: String related slow with debugger attached

Post by doublemax »

Do you see 100% cpu load (at least on one core)?
Did you try profiling the app? Maybe you can see where it spends all the time.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: String related slow with debugger attached

Post by ONEEYEMAN »

Hi,
Are you attaching the debugger to the running application or you are trying to start the debug build of the application?
Is application MT? Does it have DLLs?
Which build of wx do you use - static or dynamic?
What SDK you are trying?
Do you use C++11?

Thank, you.
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Re: String related slow with debugger attached

Post by gul_garak »

doublemax wrote:Do you see 100% cpu load (at least on one core)?
Did you try profiling the app? Maybe you can see where it spends all the time.
* I see a CPU spike, but not above 10%.
* While the application writes the XML document it blocks and it seems to spend most of its time inside constructors for wxCharTypeBuffer
and wxScopedCharTypeBuffer doing memory allocation.

Haven't been able to test STL strings yet.

Thank you!

- Alejandro
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Re: String related slow with debugger attached

Post by gul_garak »

ONEEYEMAN wrote:Hi,
Are you attaching the debugger to the running application or you are trying to start the debug build of the application?
Is application MT? Does it have DLLs?
Which build of wx do you use - static or dynamic?
What SDK you are trying?
Do you use C++11?

Thank, you.
Answers below. Thank you!

0. Starting the debug build of the app from VS.
1. MDd and it does load multiple dlls
2. static
3. Not sure what you mean? As in Windows SDK?
4. No
Last edited by gul_garak on Wed Sep 05, 2018 6:26 pm, edited 1 time in total.
gul_garak
Knows some wx things
Knows some wx things
Posts: 26
Joined: Thu Apr 05, 2018 5:19 pm

Re: String related slow with debugger attached

Post by gul_garak »

I found something that works around the issue: disabling the debug system heap. I think it doesn't affect our overall ability to debug our app so it solves this issue (I'll post again if I find any issues).

http://preshing.com/20110717/the-window ... -debugger/

https://stackoverflow.com/questions/336 ... with-debug

I'm pretty sure then that this has nothing to do with wxWidgets but for some reason it's particularly bad for wxWidgets string related operations vs the same using MFC CStrings.

Hopefully someone can use this for reference in the future if they find the same problem.

Thank you both for your help!

- Alejandro
Post Reply