Results 1 to 14 of 14

Thread: A large number of Qtimers and guarantee of clicks.

  1. #1
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default A large number of Qtimers and guarantee of clicks.

    I intend to have a fairly large number of Qtimers/ or QObject::startTimer(). By fairly large I mean around 2000. It is stated in the QTimer documentation that: http://doc.qt.io/qt-4.8/qtimer.html#details :
    If Qt is unable to deliver the requested number of timer clicks, it will silently discard some.
    Does it mean although my objects(qobject inherited) have fairly large timeouts(around a second), but if significant number of them are to be set off at the same time, some clicks will be missed?
    Or it does it mean for a particular QTimer, if the resolution is very close, some clicks will be missed.
    My application have these timer clicks as a priority. To workaround this problem, I had a complicated logic to have a single timer manage all the clicks. I like to remove it. The application is not so time critical as in it is alright if the click is off by some ms, but if there is no click at all, there will be a problem.

    And is there a limit of Qtimers. Documentation states that
    Some operating systems limit the number of timers that may be used; Qt tries to work around these limitations.
    I intend to use the application on Windows and linux desktops. And how many timers can I safely scale the system to.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    I think the logic of your application is not valid.
    Let's take an example: 2000 clock with a period of 1 s which gives 2000 signals per second. Suppose that a signal service time is 5 ms which gives 10 seconds of time to support the 2000 event. During the 10 seconds You have received 20,000 signals and serviced only 2000. How do you imagine the proper operation of the program?

  3. The following user says thank you to Lesiok for this useful post:

    pkj (26th October 2012)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by pkj View Post
    Does it mean although my objects(qobject inherited) have fairly large timeouts(around a second), but if significant number of them are to be set off at the same time, some clicks will be missed?
    No, it means that if a timer has an interval of X miliseconds but the program is executing some function (related or unrelated to the timer) that takes more than X miliseconds (e.g. 2x X) then a timeout might be discarded.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    pkj (26th October 2012)

  6. #4
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    That depends on your system. All depends on the accuracy of the system timers. The accuracy of timers depends on the underlying operating system and hardware. Are you getting any problem of missing clicks?
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  7. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: A large number of Qtimers and guarantee of clicks.

    I intend to use the application on Windows and linux desktops. And how many timers can I safely scale the system to
    It totally depends on system processing power
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  8. #6
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by Lesiok View Post
    I think the logic of your application is not valid.
    Let's take an example: 2000 clock with a period of 1 s which gives 2000 signals per second. Suppose that a signal service time is 5 ms which gives 10 seconds of time to support the 2000 event. During the 10 seconds You have received 20,000 signals and serviced only 2000. How do you imagine the proper operation of the program?
    That looks a very valid argument. I think I should stick to old idea of having a single timer managing all the timeouts. Most of 'em happen at around the same time anyway.


    Added after 11 minutes:


    Quote Originally Posted by wysota View Post
    No, it means that if a timer has an interval of X miliseconds but the program is executing some function (related or unrelated to the timer) that takes more than X miliseconds (e.g. 2x X) then a timeout might be discarded.
    If I understand correctly then the event loop of application is a kind of a endless loop.As described in this document http://doc.qt.digia.com/qq/qq11-events.html. So it is kind of always in a function?? Do you mean if it takes 2x ms in a single function? Or if the event queue is not empty?
    Last edited by pkj; 26th October 2012 at 11:11.

  9. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    Yes, event loop is a endless loop but clocktimers signals are supported by all the other.
    Let us know what you really have a problem to solve. Something we can advise you.

  10. #8
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by Lesiok View Post
    Yes, event loop is a endless loop but clocktimers signals are supported by all the other.
    Let us know what you really have a problem to solve. Something we can advise you.
    I have a large number of registers on external devices, each one of registers I represent by a QObject inherited object. Frequently I fetch up the data from these devices. If a register has a value satisfying a condition for a long enough time(lets call it delay), then I intend to emit a signal. The number of objects is intended to be scaled to be around 50000 max. Only some objects will have delays, but all may have it. Groups of these objects refresh their values by getting data from different sources.

  11. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by pkj View Post
    If I understand correctly then the event loop of application is a kind of a endless loop.As described in this document http://doc.qt.digia.com/qq/qq11-events.html. So it is kind of always in a function?? Do you mean if it takes 2x ms in a single function? Or if the event queue is not empty?
    The event loop is the thing running your timers (among doing a bunch of other stuff)

    The way timers work is that there is a list of them in the event dispatcher with noted time left to timeout. When the event loop processes events, it updates this list reducing those times by the time difference to when it was called the last time. If that value for a specific timer reaches 0, the timer is fired, its time reset and put back into the list (unless it's a single shot timer). Thus the event loop doesn't keep any history of timer timeouts -- it can't determine how many times a timer should have fired, it's only fired once at a time.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    pkj (26th October 2012)

  13. #10
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by wysota View Post
    The event loop is the thing running your timers (among doing a bunch of other stuff)

    The way timers work is that there is a list of them in the event dispatcher with noted time left to timeout. When the event loop processes events, it updates this list reducing those times by the time difference to when it was called the last time. If that value for a specific timer reaches 0, the timer is fired, its time reset and put back into the list (unless it's a single shot timer). Thus the event loop doesn't keep any history of timer timeouts -- it can't determine how many times a timer should have fired, it's only fired once at a time.
    If that is the implementation of QTimer, then it shouldn't matter whether I keep one Timer or 1000's of 'em. Essentially due to misinterpretation of the statement in doc, I had a timer with timeout of hcf of all timouts, and was juggling each timeout, to "reduce the load" !!

  14. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by pkj View Post
    If that is the implementation of QTimer, then it shouldn't matter whether I keep one Timer or 1000's of 'em.
    Not that much.

    I had a timer with timeout of hcf of all timouts, and was juggling each timeout, to "reduce the load" !!
    It will reduce a load a bit. And you'll be sure that all functionality will be executed or none of it. With multiple timers (even for the same timeout) some of them might fire more than others.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. The following user says thank you to wysota for this useful post:

    pkj (28th October 2012)

  16. #12
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by pkj View Post
    I have a large number of registers on external devices, each one of registers I represent by a QObject inherited object. Frequently I fetch up the data from these devices. If a register has a value satisfying a condition for a long enough time(lets call it delay), then I intend to emit a signal. The number of objects is intended to be scaled to be around 50000 max. Only some objects will have delays, but all may have it. Groups of these objects refresh their values by getting data from different sources.
    What is the frequency of reading a single register ?

  17. #13
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    Quote Originally Posted by Lesiok View Post
    What is the frequency of reading a single register ?
    Frequency ranges from a second to a minute. Most of 'em are batched together. So I club 'em. So if you club all coming from same instrument(read port using x protocol), and use one single timer, the number of timers decrease.
    But given the implementation of timers, separate timers for all will only save me some function over-heads at best. All instructions inside functions are best optimized by objects themselves by keeping the state up to date. But I am not sure.

  18. #14
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A large number of Qtimers and guarantee of clicks.

    I understand that the machine does not signal a readiness to read the data. I'd do it like this: for each read frequency separate thread that reads data from the registers in the loop. The thread runs one timer to read all records in order.

Similar Threads

  1. Replies: 5
    Last Post: 24th October 2011, 14:22
  2. How to efficiently display a large number of QPixmaps?
    By ChiliPalmer in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2011, 01:25
  3. Replies: 4
    Last Post: 18th August 2009, 19:53
  4. QScrollArea not displaying large number of images
    By lpkincaid in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2009, 09:58
  5. import large number of images
    By sriluyarlagadda in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2008, 10:26

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.