Details
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 *********
Qt 4.8.5 from Arch Linux repos with the aforementioned patch applied. https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/qt4&id=b70243e0a8cd491803c4464ca4d6a0690ac2d771
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 *********