aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4internalclass_p.h
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2023-12-04 10:59:52 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2023-12-05 12:50:59 +0100
commit4834aac7c9ae96e67254330dc054beb649785e63 (patch)
tree6aa7ac29ae27091e45022d558918c36b8e39fcac /src/qml/jsruntime/qv4internalclass_p.h
parent5e79d42c09a88a3614288503af99aa0c2792ad67 (diff)
JSEngine: Optimize QV4InternalClass for tests on MSVC
Running tst_ecmascripttests on MSVC in debug mode has become very slow and times out the CI. Analysing the program reveals that most of the slowdown is due to extensive wait times caused by locks. The test is run on all threads by default and this constant synchronization tanks performance. A large amount of these locks come from the fact that, in debug mode, MSVC standard containers use locks for most operations on iterators. This patch changes the container of the internal class transitions from an std::vector to a QVarLengthArray. This eliminates the iterator lock problem. The QVarLengthArray is given one inline entry to store a value. From the tests, it seems that the transitions contain only 0 or 1 entries about 84% of the time. In the remaining cases, more allocations will be needed. The additional entry will also increase the size of the containing object by 24 bytes. This should be a worthwhile tradeoff. This change alone has a significant impact on the duration of the tests. tst_ecmascripttests on 13900k with 32 threads Debug MSVC Windows Debug GCC Linux baseline: 2267s 104s QVarLengthArray 569s (~ -73%) 102s (~ -2%) This should be enough to no longer timeout the CI but many issues still remain. Change-Id: I69fefabc0375d76c817ef7d2d3b2e97dc1ace5bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r--src/qml/jsruntime/qv4internalclass_p.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h
index 4180402c92..d7b346598b 100644
--- a/src/qml/jsruntime/qv4internalclass_p.h
+++ b/src/qml/jsruntime/qv4internalclass_p.h
@@ -17,6 +17,7 @@
#include "qv4global_p.h"
#include <QHash>
+#include <QVarLengthArray>
#include <climits> // for UINT_MAX
#include <private/qv4propertykey_p.h>
#include <private/qv4heap_p.h>
@@ -315,7 +316,7 @@ struct InternalClass : Base {
SharedInternalClassData<PropertyAttributes> propertyData;
typedef InternalClassTransition Transition;
- std::vector<Transition> transitions;
+ QVarLengthArray<Transition, 1> transitions;
InternalClassTransition &lookupOrInsertTransition(const InternalClassTransition &t);
uint size;