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

Regression: QDomDocument::setContent takes nearly a minute

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 4.8.6, 5.2.0
    • Fix Version/s: 4.8.6, 5.2.1
    • Component/s: XML: DOM
    • Labels:
      None
    • Commits:
      4.8: 718fae50a4509c2cfc07552e6b1187ed2502f9b9 5.2: 62c4e288a11769bde45c9c74d731ed8628303f19

      Description

      The following change caused a serious performance regression in QDomDocument::setContent when the content contains multiple ENTITY declarations (in this case 1030).
      https://codereview.qt-project.org/70345
      qtbase/46a8885ae486e238a39efa5119c2714f328b08e4

      Before a call to QDomDocument::setContent would take about 5ms. Now it takes about 50s
      I added a little benchmark to demonstrate the problem.

      Qt built from tag v4.8.5
      Starting /build-dom_benchmark-Qt_4_8_5-Release/dom_benchmark...
      ********* Start testing of Benchmark *********
      Config: Using QTest library 4.8.5, Qt 4.8.5
      RESULT : Benchmark::setDocument():"1000":
           5 msecs per iteration (total: 5, iterations: 1)
      ********* Finished testing of Benchmark *********
      
      Starting /build-dom_benchmark-Qt_4_8_5_System-Release/dom_benchmark...
      ********* Start testing of Benchmark *********
      Config: Using QTest library 4.8.5, Qt 4.8.5
      RESULT : Benchmark::setDocument():"0":
           0 msecs per iteration (total: 0, iterations: 1)
      RESULT : Benchmark::setDocument():"50":
           6 msecs per iteration (total: 6, iterations: 1)
      RESULT : Benchmark::setDocument():"100":
           48 msecs per iteration (total: 48, iterations: 1)
      RESULT : Benchmark::setDocument():"150":
           164 msecs per iteration (total: 164, iterations: 1)
      RESULT : Benchmark::setDocument():"200":
           392 msecs per iteration (total: 392, iterations: 1)
      RESULT : Benchmark::setDocument():"250":
           761 msecs per iteration (total: 761, iterations: 1)
      RESULT : Benchmark::setDocument():"300":
           1,317 msecs per iteration (total: 1,317, iterations: 1)
      RESULT : Benchmark::setDocument():"350":
           2,143 msecs per iteration (total: 2,143, iterations: 1)
      RESULT : Benchmark::setDocument():"400":
           3,114 msecs per iteration (total: 3,114, iterations: 1)
      RESULT : Benchmark::setDocument():"450":
           4,448 msecs per iteration (total: 4,448, iterations: 1)
      RESULT : Benchmark::setDocument():"500":
           6,091 msecs per iteration (total: 6,091, iterations: 1)
      RESULT : Benchmark::setDocument():"550":
           8,102 msecs per iteration (total: 8,102, iterations: 1)
      RESULT : Benchmark::setDocument():"600":
           10,516 msecs per iteration (total: 10,516, iterations: 1)
      RESULT : Benchmark::setDocument():"650":
           13,375 msecs per iteration (total: 13,375, iterations: 1)
      RESULT : Benchmark::setDocument():"700":
           16,699 msecs per iteration (total: 16,699, iterations: 1)
      RESULT : Benchmark::setDocument():"750":
           20,541 msecs per iteration (total: 20,541, iterations: 1)
      RESULT : Benchmark::setDocument():"800":
           25,189 msecs per iteration (total: 25,189, iterations: 1)
      RESULT : Benchmark::setDocument():"850":
           30,092 msecs per iteration (total: 30,092, iterations: 1)
      RESULT : Benchmark::setDocument():"900":
           35,884 msecs per iteration (total: 35,884, iterations: 1)
      RESULT : Benchmark::setDocument():"950":
           42,160 msecs per iteration (total: 42,160, iterations: 1)
      RESULT : Benchmark::setDocument():"1000":
           48,948 msecs per iteration (total: 48,948, iterations: 1)
      ********* Finished testing of Benchmark *********
      
      Qt 5.2.0 from Arch Linux repos with the aforementioned patch applied. https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages
      Starting /build-dom_benchmark-Qt_5_2_0_System-Release/dom_benchmark...
      ********* Start testing of Benchmark *********
      Config: Using QtTest library 5.2.0, Qt 5.2.0
      RESULT : Benchmark::setDocument():"0":
           0 msecs per iteration (total: 0, iterations: 1)
      RESULT : Benchmark::setDocument():"250":
           1,200 msecs per iteration (total: 1,200, iterations: 1)
      RESULT : Benchmark::setDocument():"500":
           9,616 msecs per iteration (total: 9,616, iterations: 1)
      RESULT : Benchmark::setDocument():"750":
           32,533 msecs per iteration (total: 32,533, iterations: 1)
      RESULT : Benchmark::setDocument():"1000":
           77,056 msecs per iteration (total: 77,056, iterations: 1)
      ********* Finished testing of Benchmark *********
      

        Attachments

        1. dom_benchmark.pro
          0.1 kB
        2. main.cpp
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            mitch_curtis Mitch Curtis
            Reporter:
            mkrems Marcel Krems
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes