Performance issue after migration Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Performance issue after migration

Post by briceandre »

Dear all,

I recently migrated my development environment : starting from wxWidgets 3.0.0 with MSVC2010 compiler, I switched to wxWidgets 3.0.3 with MSVC2017 compiler.

Apart that, my application was not changed.

Before those changes, I never noticed any performance issue in my app. But now that I upgraded those two points, my application if very slower than before.

For example, the first display screen of my app is a window on which I perform some drawings in OnPaint event. With new version, I can see all elements apearing one by one, with 2 or 3 seconds for full window repaint (previous version of application was immediate).

I know that for this specific point, I could improve performances by using a buffered DC. But before doing that, I would want to understand why such a performance degradation !

Does someone has already experienced such problem after compiler migration of after migration from wxWidgets 3.0.0 to 3.0.3 ?

Thanks in advance,
Brice
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Performance issue after migration

Post by evstevemd »

I would test the old version with newer compiler to be sure that it is not the one causing issues. If not then I would try latest dev/3.1 also to see if it was not an issue that is already fixed. That will narrow the search.

Also check the changelog will be helpful in case the change is documented there.
HTH
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
coderrc
Earned some good credits
Earned some good credits
Posts: 141
Joined: Tue Nov 01, 2016 2:46 pm

Re: Performance issue after migration

Post by coderrc »

Ive had similar issues on windows with Debug builds. For me, it always went away in release builds.

Presuming that your release builds are still slow and given that vs10 vcproj files are incompatible with with newer vs versions, I'd think that some of your compiler settings may have been lost in the upgrade. As a result, the compiler is still piping in a load of unnecessary debugging symbols and data copies that would otherwise be optimized out.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Performance issue after migration

Post by doublemax »

I could improve performances by using a buffered DC.
If you're talking about wx[Auto]BufferedPaintDC, they avoid flicker, but they're actually slower in performance. If you're talking about caching drawn content until it's changed, that would be a solution. But i agree that you should find the cause for the slowdown first.
on which I perform some drawings in OnPaint event
What kind of drawings? Drawing lines and rectangles, text, bitmaps etc?

My first guess is that it's related to wxBitmap drawing operations. There were many changes in that area over the last 2 years, mostly related to drawing bitmaps into other bitmaps. One of the fixes caused a huge slowdown. However this was optimized later (still slow. but not by that much).

So: First you should check the latest wx version from GIT.
Use the source, Luke!
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Re: Performance issue after migration

Post by briceandre »

Dear all,

Thanks for your advices.

After investigation, compiler was not the cause of the issue: all seems to be linked to migration to wxWidgets 3.0.3, and in particular, in the DC stuff.

I did not migrated to wxWidgets 3.1.0 because this is still an unstable version. Instead, I came back to 3.0.0 and pacthed it slightly so that it compiles with MSVC-2017.

doublemax : I checked in my code, but the 2 OnPaint functions that caused the problems did not use bitmap to bitmap drawings. They mainly use line, polygon, square and text displays, as well as textextend computation. By the way, you suggested me to don't use bufferedDC, but instead "caching drawn content". Could you explain what you mean from that ? I would be interested in improving this part of the code as it seems that, even if with wxWidgets 3.0.0 version, it has acceptable performances, it is a weak part of my program in terms of perfs.

To be honest with you, the only way I am thinking of to improve this part would be to draw once for all the background of the window in a bitmap, and copy the bitmap to the DC in the OnPain event. But after your comment about the bitmap drawing perf issue on wxWidgets 3.0.3, I am not sure this is the proper approach.

Many thanks,
Brice
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Performance issue after migration

Post by doublemax »

By the way, you suggested me to don't use bufferedDC, but instead "caching drawn content". Could you explain what you mean from that ?
be to draw once for all the background of the window in a bitmap, and copy the bitmap to the DC in the OnPain event.
That's what i meant. Only use the drawing functions when the content changes, otherwise blit from a bitmap. This is only useful if the background is mainly static and doesn't change often.
Use the source, Luke!
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Re: Performance issue after migration

Post by briceandre »

OK, thanks.

I thought that you discouraged copying from bitmap to DC. But I probably misunderstood.

I will give it a try because the major part of the drawing is static.

Thanks for suggestions.

Brice
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Performance issue after migration

Post by doublemax »

I thought that you discouraged copying from bitmap to DC. But I probably misunderstood.
I'm not quite sure in which wxWidgets version the slow code was, but it was only there for a short time. At least in the current version from GIT, it should be safe to use all bitmap operations again.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Performance issue after migration

Post by PB »

FWIW, you can check here for a workaround if you are using a buffered DC and experiencing a major slowdown:
http://trac.wxwidgets.org/ticket/14403#comment:45, not sure if it is relevant to your case and which wxWidgets versions are actually affected.
Post Reply