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

QVariant performance regression in Qt6

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 6.0.1
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      All

      Description

      I tried a simple benchmark of new QVariant in Qt6 and it shows significant slowdown (2 to 3 times) when compared to Qt5.

      QElapsedTimer t;
      t.start();
      int sum = 0;
      for (int i = 0; i < 100000000; ++i)
      {
          int a = 1;
          QVariant v = a;
          int b = v.toInt();
          sum += b;
      }
      qDebug() << sum << t.elapsed();
      

      On my environment (Windows 10, MSVC 2019, 64bit) the measured times are around 1.5 secs with Qt 6.0.1 and 0.6 secs with Qt 5.15.2. This is 2.5x slowdown.

      I measured similar slowdowns with QString.

      I know that these numbers quite insignificant per se and conversions are still fast in most real life situations, but this can mean that QVariant usage becomes a burden in some performance heavy scenarios. Natural example which comes to my mind is sorting of a large data model which require conversions to/from QVariant of each value.

      But maybe there is potential for some type specialization for most prevalent types such asĀ int, double or QString which could regain some more performance.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-90560
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              fabiankosmale Fabian Kosmale
              Reporter:
              vladimir.kraus Vladimir Kraus
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes