Performance issues with wxBitmap & wxDC under GTK

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
dmadhava
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri May 27, 2005 9:42 pm

Performance issues with wxBitmap & wxDC under GTK

Post by dmadhava » Thu Jul 21, 2005 6:33 pm

Hi,

I am trying to draw an image in my OnPaint() event handler and it seems to be taking for ever to paint the image. Here is the code snippet:

Code: Select all

    wxBitmap backing(background);
    
    wxPaintDC dc(this);
    dc.BeginDrawing();
    dc.DrawBitmap(background, 0, 0, false);
    dc.EndDrawing();
The above code takes about 8-10 seconds to run. The background image is 400x400 in size. I am using wxWidgets-2.6.1, under RedHat 9.0 stock. Is anybody else experiencing performance issues? Any suggestions to work around is appreciated.

thanks

with regards
-DJ

dmadhava
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri May 27, 2005 9:42 pm

Looks like the network & xServer that influence speed

Post by dmadhava » Thu Jul 21, 2005 10:06 pm

Hello,

In pursuit to try and troubleshoot my problems further, I tried different combinations of XServers and networks, including running directly on the host machine. From my observations it looks like the primary source of the performance bottleneck lies in creation of the bitmap from the image. Namely, the statement:

Code: Select all

wxBitmap backing(background);
is the one that is taking all the time. Now, the question becomes why does it take so much time? My guess is that the speed of communication between the xServer and host seems to be the most critical factor. However, my question then becomes why is it so? Why is GTK's implementation of wxBitmap so demanding on the communication with the XServer? I don't have the background to answer that question. Can somebody else throw some light?

In general I am not sure if you guys are concerend about performance related issues. If you guys are not, I apologize for the noise -- but I am hoping the discussions will be beneficial to someone else.

leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Re: Looks like the network & xServer that influence spee

Post by leio » Thu Jul 21, 2005 10:14 pm

dmadhava wrote:Why is GTK's implementation of wxBitmap so demanding on the communication with the XServer? I don't have the background to answer that question. Can somebody else throw some light?

In general I am not sure if you guys are concerend about performance related issues. If you guys are not, I apologize for the noise -- but I am hoping the discussions will be beneficial to someone else.
I am interested to know about performance related issues in case of wxGTK.
One thing I plan to work on is proper wxGTK dual-head support, and after that X11 over network wxGTK issues.
Is it in your case slow only over network (LAN) or also when running on the same comp?
My project draws the entire screen all the time in OnPaint, and I see no issues if it's done on the host itself - not sure about over network, I think it worked at least better than you describe.
In case of a network, a possible problem could be that the image needs to be sent as a whole, and the bitmap isn't stored as a X11 resource, that gets an id and would be sent only once.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/

dmadhava
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri May 27, 2005 9:42 pm

Guess: Slowdown primarily due to network latencies

Post by dmadhava » Thu Jul 21, 2005 11:28 pm

Hi,

I think the slowdown is primarily due to network latencies. If I run the code directly on the host (without the network in the middle) it is relatively fast. For example if I run it directly on the host, then the time to create a wxBitmap from a wxImage is about 30 to 50 milliseconds [I still think this is kinda slow given that I create the image in less than 2 seconds and the wxDC.DrawBitmap() method executes in less than 1 millisecond]. If I run the code on my LAN (100 MBPS) it takes about 1.5 seconds to create the bitmap. Lastly, if I run it over the web (via a 128 KBPS cable modem) it takes about 8-9 seconds! Here is a table for ready reference:
<TABLE Border="1">
<TR><TD Align="center"><b>Network</b></TD><TD Align="center"><b>Time(wxBitmap(wxImage))</b><br>(milliseconds)</TD></TR>

<TR><TD>None</TD><TD>30-50</TD></TR>

<TR><TD>LAN (100 MBPS)</TD><TD>1250-1575</TD></TR>

<TR><TD>Internet(128 KBPS)</TD><TD>8975-9820</TD></TR>

</TABLE>

Any ideas why creation of the bitmap from an image would become so slow? I understand rendering the final image over the network could be slow but why is creating a bitmap from a image so slow? I am baffled.

thanks

with regards
-DJ

Post Reply