Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-47177

Windows event loop excessive CPU usage with multiple timers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.3.1
    • Core: Event loop
    • None
    • Windows 7 Desktop 64-bit

    Description

      Windows event loop actually keeps track off all processed timer to avoid live-lock as stated in code comment.

       // avoid live-lock by keeping track of the timers we've already sent
      bool found = false;
      for (int i = 0; !found && i < processedTimers.count(); ++i) {
          const MSG processed = processedTimers.constData()[i];
          found = (processed.wParam == msg.wParam && processed.hwnd == msg.hwnd && processed.lParam == msg.lParam);
          }
          if (found)
              continue;
          processedTimers.append(msg);
      

      I was using application wkhtmltopdf, which internally uses webkit to convert input document to pdf. I found out, that there are many timers used in this toolchain and my application hanged most of the time in windows event loop, with numbers of processed timers almost equal to number of pdf pages rendered (3000+).

      I wasn't sure, what is the reason to keep track of all timers, but I've changed processedTimers to be QSet instead of QVarLengthArray, which is really slow.

      My patch is attached for review.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            Gotcha Juraj Zikmund
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes