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

QVariant performance regression in Qt6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.0.1
    • None
    • 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

              fabiankosmale Fabian Kosmale
              vladimir.kraus Vladimir Kraus
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes