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

Repeated calls to QTextCodec::codecForName() requesting the same codec is very slow.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.6.3
    • 4.6.1
    • None
    • Nokia Symbian^3
    • b3b7796178f6a94fc46ef827b01a46420dae5a50

    Description

      Repeated calls to QTextCodec::codecForName() requesting the same codec is very slow.

      We have a usecase in webkit where NPAPIs used frequently. For each NPAPI call the string is processed by WebCore and the text is converted via QTextCodec. It is always using the same UTF-8 encoding. QTextCodec is maintaining a static list of all codecs as singletons, but it does text comparisons for all names and aliases in order to find the correct codec.

      In our use case, we have found that looking up the codec is using over 50%of the CPU time and is extremely slow. We proppose to add a simple LRU fast cache in order to remove the duplicate work in retrieving the same codec over and over again.

      The bug was logged to webkit but it has been suggested to move the cache to Qt's corelib.
      https://bugs.webkit.org/show_bug.cgi?id=34489

      Please find attached a sample implementation of a faster look up by storing the last used codec.

      Attachments

        Issue Links

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

          Activity

            People

              goffart Olivier Goffart (closed Nokia identity) (Inactive)
              david.leong@nokia.com David Leong
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes