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

Question about the performance of method calls

    XMLWordPrintable

Details

    • 17bd07cbc5 (qt/qtdeclarative/dev) 17bd07cbc5 (qt/tqtc-qtdeclarative/dev)

    Description

      Hello,
      I am trying to improve performance of the QML scripts in my app.

      While looking at traces, there is something that seems pretty weird to me.
      I have the following code in QML:

            for(let s = 0; s < n; s++) {
              let sample =  /* some small computation, e.g. Math.sin */;
              out1.setSample(0, s, sample);
              out1.setSample(1, s, sample);
            }
      

      out1 is a C++ QObject with the following slot:

          void setSample(int i, int j, double v)
          {
            // c is a std::vector<std::vector<double>>
            c[i][j] = v;
          }
      

      when I look at the trace, I notice that every time setSample is called, there's a loong call to QV4::QObjectMethod::create which seems to do a lot of stuff, and allocate a lot of memory.
      Like, all in all, my actual c++ method call, visible at the left (JS::AudioOutlet::...) is 1% of the total of the call... and I'm in a debug build !

      Is this 100x performance penalty a fact of life of QML which cannot be avoided ? Is there some missed optimization / caching opportunity lost here ? (e.g. I'd assume something like a per-metaobject method cache?)

      Attachments

        1. QTBUG-95628.tar.gz
          6 kB
        2. that.png
          that.png
          216 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ulherman Ulf Hermann
            jcelerier Jean-Michaël Celerier
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change