Results 1 to 14 of 14

Thread: Qwt 6.0.1 three times slower than 5.2.0

  1. #1
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Question Qwt 6.0.1 three times slower than 5.2.0

    Hello,

    I'm new to the forum so I would like to take this opportunity and say "Hi" to everyone.

    I'm using Qt for several years now but I'm fairly new to Qwt.

    At the moment I'm evaluating if it's worth moving to Qwt 6.0.1 from 5.2.0.
    6.0.1 has many new and interesting features but there's a problem.
    I was able to plot 2 million points in less than 1500ms but after moving to 6.0.1 the same operation takes 5000ms+!

    Quick look at what's going on revealed that using QPainter:drawPolyline() in the float version seems to kill the performance (forcing qwt to use int version takes 2000ms to plot 2 million points).

    Is there a way to switch qwt to use integers?
    I think I know the answer, so I'll follow up with another question - why qwt is using now floats when the performance is so much poorer?

    Is there anything I could do to improve the performance (except messing with qwt source)?

    Best Regards!

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Quote Originally Posted by Spitfire View Post
    ... why qwt is using now floats
    Because of backends, that are float ( today PDF/SVG ) based. The main use case is PDF, where you can zoom in/out later in the PDF viewer seeing differences between points, that are mapped to the same position in default resolution.

    Quote Originally Posted by Spitfire View Post
    Quick look at what's going on revealed that using QPainter:drawPolyline() in the float version seems to kill the performance (forcing qwt to use int version takes 2000ms to plot 2 million points).!
    Please do more than a quick look - there are a couple of other differences between 5.2 and 6.0. F.e the default setting for polygon clipping is enabled on Qwt 6.

    • Can you isolate the issue to a small demo application, where you paint your points with QPainter to a QWidget ?
    • If there is really a major difference between painting QPolygon and QPolygonF I would expect to have an effect that is platform specific ?


    Quote Originally Posted by Spitfire View Post
    Is there a way to switch qwt to use integers?
    In the end Qt has to map the floats to integers on platforms, where the graphics system is integer based. Because this rounding is often different to what Qwt objects need almost all Qwt plot items check the graphics system first and does the rounding itself. So QwtPlotCurve has in fact integers in most cases and it would be no big deal to use QPolygon instead of QPolygonF there.

    Is there anything I could do to improve the performance (except messing with qwt source)?
    IMHO even 2000ms is poor.

    The common way to improve performance for curves with many points is to implement different levels of detail. This has been discussed many times in this forum - check the archive.

    Uwe

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Hey Uwe,
    Thanks for so quick reply.

    I know that there's more changes than this. Like instant paint being set to false by default but none of them (I had polygon clipping enabled already) seems to affect performance in the way using floats does.

    To get more information I've followed your suggestion that the problem is platform dependent.
    Everything I've said till now was based on 64bit Windows 7 os.
    I've build the same app on 64bit Ubuntu (same box) and it works much faster. Plotting 2m points with Qwt 5.2.0 takes 250ms.
    Qwt 6.0.1 is still slower but the difference is not that noticeable - the same 2m points took 400ms to plot.
    I wish I could make it work like that on windows!

    I will test it further like you mentioned, but for now you can see what I mean by altering static inline void drawPolyline() function in qwt_painter.cpp to look just like this:
    Qt Code:
    1. {
    2. QTime tt;
    3. QVector<QPoint> p;
    4.  
    5. for(int i = 0; i < pointCount; ++i)
    6. p.append(points[i].toPoint());
    7.  
    8. tt.start();
    9. painter->drawPolyline( points, pointCount );
    10. std::cout << "Float draw took " << tt.elapsed() << "ms to complete." << std::endl;
    11.  
    12. tt.restart();
    13. painter->drawPolyline( p.data(), pointCount );
    14. std::cout << "Int draw took " << tt.elapsed() << "ms to complete." << std::endl;
    15. }
    To copy to clipboard, switch view to plain text mode 
    In my case rendering 2m points on w7 yelds this output:
    Qt Code:
    1. Float draw took 3009ms to complete.
    2. Int draw took 1199ms to complete.
    To copy to clipboard, switch view to plain text mode 

    Do you have any suggestions how to speed up rendering on windows (except level of details you've already mentioned)?
    5.2.0 speed was acceptable where 6.0.1 is not user friendly at all.

    Cheers!

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Like instant paint being set to false by default but none of them (I had polygon clipping enabled already) seems to affect performance in the way using floats does.
    Well polygon clipping improves performance significantly, when there is something to clip. Guess in your case this is not true ( as long as you don't zoom in/out ), so you might want to disable polygon clipping. AFAIR there was another optimization in Qwt 5.x, that drops points when they are mapped to the same position as its predecessor, what does make sense for integer coordinates only.

    I've build the same app on 64bit Ubuntu (same box) and it works much faster. Plotting 2m points with Qwt 5.2.0 takes 250ms.
    Qwt 6.0.1 is still slower but the difference is not that noticeable - the same 2m points took 400ms to plot.
    I wish I could make it work like that on windows!
    Well with X11 painting is done asynchronously from the X server - so your numbers might compare apples and eggs.
    But the time spent on the X server doesn't depend on doubles or ints - so the overhead of 150 ms is an interesting value.

    When you start your application with "-graphicssystem raster" I would expect to see similar results on Ubuntu like on Windows ?

    Do you have any suggestions how to speed up rendering on windows (except level of details you've already mentioned)?
    5.2.0 speed was acceptable where 6.0.1 is not user friendly at all.
    Of course Qwt ( not application ! ) code is where workarounds should to be added - but in the end it is a Qt problem and should be identified and maybe fixed there too. A small demo ( Qt only ) demonstrating the issue is always required.

    At the moment there are a couple of facts missing:

    • Qt version
    • QPen attributes used
    • QPainter render hints
    • ...

    Uwe

  5. #5
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    I'm using Qt 4.6.3,
    Painter and pen settings are default (QPainter::TextAntialiasing, pen solid line, 1px black).

    When I've launched the app on Ubuntu with -graphicssystem raster both versions are slower, but not even close to what's happening on windows.
    5.2.0 plots 2m points in 340ms (as oposite to 250ms), 6.0.1 plots 2m points in 770ms (as opposite to 400ms).

    I'll take your suggestion and tomorrow I'll write simple pure Qt app to verify if the issue lies with Qt or not and post it here.

    Anyway, it may be worth considering adding a way of selecting which rendering system to use (int or double) as not everybody (for example me ) needs double precision.

    I'll keep you updated.

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Quote Originally Posted by Spitfire View Post
    Painter and pen settings are default (QPainter::TextAntialiasing, pen solid line, 1px black).
    The default is a pen width of 0 - a pen width of 1 is running into a different render path and might be significantly slower,

    Uwe

  7. #7
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    I've done simple Qt example of painting using float and integers (attached) and on windows - the results is the same.
    Floats are dead slow.

    I did some search through Qt bug database and I found an issue complaining about drawpolyline being slow with antialiasing, but it's not the case here.

    Any chances of getting a way of using ints instead of doubles for drawing in Qwt 6.x.x?
    I can't see any other way of making it any faster
    Attached Files Attached Files

  8. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Do you have a similar effects on 32bit systems - and of course with Qt 4.7.x ?

    Uwe

  9. #9
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    I don't have access to any 32bit system at the moment, but I'll check it over the weekend and let you know.

  10. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Quote Originally Posted by Spitfire View Post
    I've done simple Qt example of painting using float and integers (attached) and on windows - the results is the same.
    I checked your code on my box ( Linux/X11, Qt 4.7.3 ):

    • With basic X11 using floats is significantly faster ( about 10-30 % )
    • Enabling the raster paint engine ( -graphicssystem raster ) I can confirm that doubles are much slower ( about 200-250 % )

    So the "right" solution means obviously more than simply using integers instead of floats.

    I will check the code of the raster paint engine why it performs so bad for floats.

    Uwe

  11. #11
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    I've tested 32bit Windows XP box.

    The problem is the same, with 5.2.0 plot is rendered in 1700ms, with 6.0.1 it takes 5600ms.

    Let me know if you find anything interesting.
    Cheers!

  12. #12
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    In SVN trunk ( Qwt 6.1 ) QwtPlotCurve tries to use QPolygon instead of QPolygonF ( depending on various parameters ).

    If you don't want to have this optimization you can enable the new flag QwtPlotItem::RenderFloats. Like expected setting this flag slows down the frame rate of the refreshtest example, when using the raster graphics system.

    Uwe

  13. #13
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    Just one more hint: in Qwt 5.2 was a flag QwtPlotCurve::PaintFiltered that removes points that are mapped to the same position as their predecessor. As long as your samples are not only noise it should have a much bigger impact on the performance than the QPolygon/QPolygonF flag.

    I have reintroduced this optimization to Qwt 6.1 ( QwtPlotCurve::FilterPoints ). In situations, where the curve is rendered to an integer based paint engine ( all beside Svg and Pdf ) I would expect, that it will reduce the polygon heavily for a 2 million point series.

    You can check the refreshtest example to see its effect.

    Uwe

  14. #14
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt 6.0.1 three times slower than 5.2.0

    That's great to hear.

    I'll grab 6.1 and build my project against it.

    I'll let you know if everything works fine.

    Thanks!

    The QwtPlotCurve::FilterPoints flags speeds up everything very nicely but the algorithm seems to lose sudden peaks in the graph (see attached example - the same curve with QwtPlotCurve::FilterPoints enabled and disabled).

    On windows box 6.1 is still slower than 5.2 but the difference is not that big now. Now it takes around 2500ms to plot 2m points.

    X values on my plots are always indexes which translate to time. I did some work on algorithm that takes all points that would be rendered into one pixel wide column on the screen and creates a line out of it.
    Then it renders all the lines on the screen. In worst case there will be as many lines as there is horizontal pixels on the screen.
    This way rendering 2M points takes ~100ms including running the algorithm, ~250ms for 5M and ~500ms for 10M points with no loses to the details like sudden, short lived peaks (see attachment).

    If you're interested I can post the code here.
    Attached Images Attached Images
    Last edited by Spitfire; 26th September 2011 at 10:04.

Similar Threads

  1. QVector Slower than STL Vector
    By lynchkp in forum Newbie
    Replies: 3
    Last Post: 5th December 2010, 10:50
  2. Qt 4.6.3 slower than 4.6.2
    By Nik8768 in forum Installation and Deployment
    Replies: 3
    Last Post: 19th July 2010, 12:13
  3. Replies: 6
    Last Post: 15th April 2010, 19:56
  4. Replies: 11
    Last Post: 2nd July 2009, 00:41
  5. why Qt4 is so slower than Qt3 ?
    By xuyaojun1980 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 11th February 2009, 18:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.