VirtualBox

Changeset 82131 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 23, 2019 5:58:45 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134941
Message:

FE/Qt: Statistics have moved again. Optimized statistics querying by doing exact queries for each graphs rather than combining them, the difference is tree lookup vs full tree enumeration. Also fixed the borked UIDebuggerMetricData.m_strName initialization, it would get the raw xml string rather than just the value of the 'name' attribute (QStringRef). bugref:9510

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationPerformanceMonitor.cpp

    r81793 r82131  
    838838        foreach (const QString &strSubString, m_metricDataSubString)
    839839        {
     840            /** @todo r=bird: It is much more efficient to (1) start a query with '/' and
     841             *        (2) not use multiple expressions.  If you don't start with '/',
     842             *        STAM must search all the statistics.  If you have multiple
     843             *        expressions it is not yet clever enough to optimize the search and
     844             *        will search all the statistics.  There are several thousand in a
     845             *        debug builds, some 400-600 in a typical release build (config dep). */
    840846            m_strQueryString += QString("*%1*%2*%3*|").arg(m_strQueryPrefix).arg(strDeviceName).arg(strSubString);
    841847        }
     
    10631069    }
    10641070
    1065     /* Collect the data from IMachineDebugger::getStats(..): */
    1066     quint64 uNetworkTotalReceive = 0;
    1067     quint64 uNetworkTotalTransmit = 0;
    1068     quint64 uDiskIOTotalWritten = 0;
    1069     quint64 uDiskIOTotalRead = 0;
    1070     quint64 uTotalVMExits = 0;
    1071 
    1072     QVector<UIDebuggerMetricData> xmlData = getTotalCounterFromDegugger(m_strQueryString);
    1073     for (QMap<QString, UIMetric>::iterator iterator =  m_metrics.begin();
    1074          iterator != m_metrics.end(); ++iterator)
    1075     {
    1076         UIMetric &metric = iterator.value();
    1077         const QStringList &deviceTypeList = metric.deviceTypeList();
    1078         foreach (const QString &strDeviceType, deviceTypeList)
     1071    /* Update the network load chart with values we find under /Public/NetAdapter/: */
     1072    {
     1073        quint64 cbNetworkTotalReceived = 0;
     1074        quint64 cbNetworkTotalTransmitted = 0;
     1075        QVector<UIDebuggerMetricData> xmlData = getAndParseStatsFromDebugger("/Public/NetAdapter/*/Bytes*");
     1076        foreach (const UIDebuggerMetricData &data, xmlData)
    10791077        {
    1080             foreach (const UIDebuggerMetricData &data, xmlData)
    1081             {
    1082                 if (data.m_strName.contains(strDeviceType, Qt::CaseInsensitive))
    1083                 {
    1084                     if (metric.name() == m_strNetworkMetricName)
    1085                     {
    1086                         if (data.m_strName.contains("receive", Qt::CaseInsensitive))
    1087                             uNetworkTotalReceive += data.m_counter;
    1088                         else if (data.m_strName.contains("transmit", Qt::CaseInsensitive))
    1089                             uNetworkTotalTransmit += data.m_counter;
    1090                     }
    1091                     else if (metric.name() == m_strDiskIOMetricName)
    1092                     {
    1093                         if (data.m_strName.contains("written", Qt::CaseInsensitive))
    1094                             uDiskIOTotalWritten += data.m_counter;
    1095                         else if (data.m_strName.contains("read", Qt::CaseInsensitive))
    1096                             uDiskIOTotalRead += data.m_counter;
    1097                     }
    1098                     else if (metric.name() == m_strVMExitMetricName)
    1099                     {
    1100                         if (data.m_strName.contains("RecordedExits", Qt::CaseInsensitive))
    1101                             uTotalVMExits += data.m_counter;
    1102                     }
    1103                 }
    1104             }
     1078            if (data.m_strName.endsWith("BytesReceived"))
     1079                cbNetworkTotalReceived += data.m_counter;
     1080            else if (data.m_strName.endsWith("BytesTransmitted"))
     1081                cbNetworkTotalTransmitted += data.m_counter;
     1082            else
     1083                AssertMsgFailed(("name=%s\n", data.m_strName.toLocal8Bit().data()));
    11051084        }
    1106     }
    1107     updateNetworkGraphsAndMetric(uNetworkTotalReceive, uNetworkTotalTransmit);
    1108     updateDiskIOGraphsAndMetric(uDiskIOTotalWritten, uDiskIOTotalRead);
    1109     updateVMExitMetric(uTotalVMExits);
    1110 }
    1111 
     1085        updateNetworkGraphsAndMetric(cbNetworkTotalReceived, cbNetworkTotalTransmitted);
     1086    }
     1087
     1088    /* Update the Disk I/O chart with values we find under /Public/Storage/?/Port?/Bytes*: */
     1089    {
     1090        quint64 cbDiskIOTotalWritten = 0;
     1091        quint64 cbDiskIOTotalRead = 0;
     1092        QVector<UIDebuggerMetricData> xmlData = getAndParseStatsFromDebugger("/Public/Storage/*/Port*/Bytes*");
     1093        foreach (const UIDebuggerMetricData &data, xmlData)
     1094        {
     1095            if (data.m_strName.endsWith("BytesWritten"))
     1096                cbDiskIOTotalWritten += data.m_counter;
     1097            else if (data.m_strName.endsWith("BytesRead"))
     1098                cbDiskIOTotalRead += data.m_counter;
     1099            else
     1100                AssertMsgFailed(("name=%s\n", data.m_strName.toLocal8Bit().data()));
     1101        }
     1102        updateDiskIOGraphsAndMetric(cbDiskIOTotalWritten, cbDiskIOTotalRead);
     1103    }
     1104
     1105    /* Update the VM exit chart with values we find as /PROF/CPU?/EM/RecordedExits: */
     1106    {
     1107        quint64 cTotalVMExits = 0;
     1108        QVector<UIDebuggerMetricData> xmlData = getAndParseStatsFromDebugger("/PROF/CPU*/EM/RecordedExits");
     1109        foreach (const UIDebuggerMetricData &data, xmlData)
     1110        {
     1111            if (data.m_strName.endsWith("RecordedExits"))
     1112                cTotalVMExits += data.m_counter;
     1113            else
     1114                AssertMsgFailed(("name=%s\n", data.m_strName.toLocal8Bit().data()));
     1115        }
     1116        updateVMExitMetric(cTotalVMExits);
     1117    }
     1118}
     1119
     1120/**
     1121 *
     1122 * @returns
     1123 */
    11121124void UIInformationPerformanceMonitor::sltGuestAdditionsStateChange()
    11131125{
     
    11471159
    11481160    m_metrics.insert(m_strCPUMetricName, UIMetric(m_strCPUMetricName, "%", iMaximumQueueSize));
     1161/** @todo r=bird: This way of constructing queries is inefficient, see
     1162 *        comment in query composer.  Also, both the network and disk bits
     1163 *        have moved now.  The update timer method has been updated and no
     1164 *        longer makes use of this for the statistics querying. */
    11491165    {
    11501166        /* Network metric: */
     
    11521168        networkMetric.setQueryPrefix("Public");
    11531169        QStringList networkDeviceList;
    1154         networkDeviceList << "E1k" <<"VNet" << "PCNet";
     1170        networkDeviceList << "E1k" << "VNet" << "PCNet";
    11551171        networkMetric.setDeviceTypeList(networkDeviceList);
    11561172        QStringList networkMetricDataSubStringList;
     
    14101426}
    14111427
    1412 QVector<UIDebuggerMetricData> UIInformationPerformanceMonitor::getTotalCounterFromDegugger(const QString &strQuery)
     1428QVector<UIDebuggerMetricData> UIInformationPerformanceMonitor::getAndParseStatsFromDebugger(const QString &strQuery)
    14131429{
    14141430    QVector<UIDebuggerMetricData> xmlData;
    14151431    if (strQuery.isEmpty())
    14161432        return xmlData;
    1417     CMachineDebugger debugger = m_console.GetDebugger();
    1418     QString strStats = debugger.GetStats(strQuery, false);
     1433    QString strStats = m_machineDebugger.GetStats(strQuery, false);
    14191434    QXmlStreamReader xmlReader;
    14201435    xmlReader.addData(strStats);
    1421     quint64 iTotal = 0;
    14221436    if (xmlReader.readNextStartElement())
    14231437    {
     
    14281442                QXmlStreamAttributes attributes = xmlReader.attributes();
    14291443                quint64 iCounter = attributes.value("c").toULongLong();
    1430                 iTotal += iCounter;
    1431                 xmlReader.skipCurrentElement();
    1432                 xmlData.push_back(UIDebuggerMetricData(*(attributes.value("name").string()), iCounter));
     1444                xmlData.push_back(UIDebuggerMetricData(attributes.value("name"), iCounter));
    14331445            }
    14341446            else if (xmlReader.name() == "U64")
     
    14361448                QXmlStreamAttributes attributes = xmlReader.attributes();
    14371449                quint64 iCounter = attributes.value("val").toULongLong();
    1438                 iTotal += iCounter;
    1439                 xmlReader.skipCurrentElement();
    1440                 xmlData.push_back(UIDebuggerMetricData(*(attributes.value("name").string()), iCounter));
     1450                xmlData.push_back(UIDebuggerMetricData(attributes.value("name"), iCounter));
    14411451            }
    1442             else
    1443                 xmlReader.skipCurrentElement();
     1452            xmlReader.skipCurrentElement();
    14441453        }
    14451454    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationPerformanceMonitor.h

    r81109 r82131  
    5353    UIDebuggerMetricData()
    5454        : m_counter(0){}
    55     UIDebuggerMetricData(const QString & strName, quint64 counter)
    56         :m_strName(strName)
     55    UIDebuggerMetricData(const QStringRef & strName, quint64 counter)
     56        : m_strName(strName.toString())
    5757        , m_counter(counter){}
    5858    QString m_strName;
     
    181181    QString dataColorString(const QString &strChartName, int iDataIndex);
    182182    /** Parses the xml string we get from the IMachineDebugger and returns an array of UIDebuggerMetricData. */
    183     QVector<UIDebuggerMetricData> getTotalCounterFromDegugger(const QString &strQuery);
     183    QVector<UIDebuggerMetricData> getAndParseStatsFromDebugger(const QString &strQuery);
    184184
    185185    bool m_fGuestAdditionsAvailable;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette