Marc Mutz 4a1de91066 QMetaObject: fix performance regression in methodMatch()
Amends 22ce92f8040183faf9e1ba53c59c6b0b9172fb26, which apparently
changed the method name stored in the moc data from unqualified to a
qualified name. The original commit message doesn't mention it, but
the change in QMetaMethodPrivate::name() suggests as much.

Unfortunately, the search for the colon causes the name() call to
increase to 25% of the total methodMatch() runtime, up from 6.85%
before the change.

Since name() now always strips a possible prefix, re-add the original
name() as qualifiedName() and use that in methodMatch().

This is faster because we don't need to perform an a-priori search for
colons; instead, we can first check for endsWith(), and only if we
have a match, can we a-posteriori check that the match was preceded by
an (optional) colon.

Results on my machine:

  ********* Start testing of tst_QObject *********
  Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 15.0.3 (github.com:llvm/llvm-project.git 48b23aa469b8cfdb6cde1c55bf3361cabcdef6bc)), ubuntu 20.04
  PASS   : tst_QObject::initTestCase()
  PASS   : tst_QObject::connect_disconnect_benchmark(normalized signature)
  RESULT : tst_QObject::connect_disconnect_benchmark():"normalized signature":
  -    923.542494 nsecs per iteration (total: 461,771,247, iterations: 500000)
  +    880.558792 nsecs per iteration (total: 440,279,396, iterations: 500000)
  -    4,340.832532 CPU cycles per iteration, 4,7 GHz (total: 2,170,416,266, iterations: 500000)
  +    4,093.487614 CPU cycles per iteration, 4,65 GHz (total: 2,046,743,807, iterations: 500000)
  -    13,706.07561 instructions per iteration, 3,157 instr/cycle (total: 6,853,037,807, iterations: 500000)
  +    12,779.02463 instructions per iteration, 3,122 instr/cycle (total: 6,389,512,318, iterations: 500000)
  -    2,201.185595 branch instructions per iteration, 2,38 G/sec (total: 1,100,592,798, iterations: 500000)
  +    2,208.176500 branch instructions per iteration, 2,51 G/sec (total: 1,104,088,250, iterations: 500000)

For a ~5% overall speedup in both ns/iter and instr/iter, keeping in
mind that this data contains the disconnect() call, too.

As a drive-by, remove a second call of QMetaObjectPrivate::get() on the
same object, and reuse the previous call's result.

Task-number: QTBUG-135572
Change-Id: Ide253b323e7b826f8fa09d2f5f57496861c12f75
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 8e98a3a82602016b2e9bfe2435031ae6ff8010e7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-13 17:52:22 +00:00
2025-03-24 18:27:25 +00:00
2024-11-05 14:36:16 +01:00
2024-11-05 14:36:16 +01:00
2025-03-25 08:40:27 +00:00
2024-06-25 11:44:00 +02:00
Description
Qt Base (Core, Gui, Widgets, Network, ...)
822 MiB
Languages
C++ 84.3%
HTML 4.9%
C 3.9%
CMake 3.6%
Objective-C++ 2%
Other 0.8%