summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-05-18 16:48:24 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-05-22 11:04:00 +0000
commitbaa68e95a6c0f4df1ab04aa7cecefe95d360c691 (patch)
tree2204a814e18a87cc9e3b4c6e4562395b31299468
parent15e0c94820acdb276e5a6285cdf203dfb5df8107 (diff)
Send auxiliary timestamped messages in order with samples
Having a common chronological ordering between all timestamped events, at least most of the time, makes it so much less painful to process the stream on the client side. Change-Id: I8531a9b66c599c1c35688ad907ab403a41c11ba6 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
-rw-r--r--app/perfunwind.cpp16
-rw-r--r--app/perfunwind.h3
2 files changed, 14 insertions, 5 deletions
diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp
index 179ea7e..0bf5e5a 100644
--- a/app/perfunwind.cpp
+++ b/app/perfunwind.cpp
@@ -134,6 +134,8 @@ PerfUnwind::~PerfUnwind()
{
finishedRound();
flushEventBuffer(0);
+ for (const QByteArray &aux : qAsConst(m_auxBuffer))
+ sendBuffer(aux);
delete[] m_debugInfoPath;
qDeleteAll(m_symbolTables);
@@ -207,7 +209,7 @@ void PerfUnwind::comm(const PerfRecordComm &comm)
QDataStream(&buffer, QIODevice::WriteOnly) << static_cast<quint8>(Command)
<< comm.pid() << comm.tid() << comm.time()
<< commId;
- sendBuffer(buffer);
+ m_auxBuffer.insert(comm.time(), buffer);
}
void PerfUnwind::attr(const PerfRecordAttr &attr)
@@ -266,7 +268,7 @@ void PerfUnwind::lost(const PerfRecordLost &lost)
QByteArray buffer;
QDataStream(&buffer, QIODevice::WriteOnly) << static_cast<quint8>(LostDefinition)
<< lost.pid() << lost.tid() << lost.time();
- sendBuffer(buffer);
+ m_auxBuffer.insert(lost.time(), buffer);
}
void PerfUnwind::features(const PerfFeatures &features)
@@ -601,6 +603,12 @@ void PerfUnwind::analyze(const PerfRecordSample &sample)
}
}
+ for (auto it = m_auxBuffer.begin();
+ it != m_auxBuffer.end() && it.key() < sample.time();
+ it = m_auxBuffer.erase(it)) {
+ sendBuffer(it.value());
+ }
+
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
stream << static_cast<quint8>(type) << sample.pid()
@@ -628,7 +636,7 @@ void PerfUnwind::fork(const PerfRecordFork &sample)
QDataStream(&buffer, QIODevice::WriteOnly) << static_cast<quint8>(ThreadStart)
<< sample.childPid() << sample.childTid()
<< sample.time();
- sendBuffer(buffer);
+ m_auxBuffer.insert(sample.time(), buffer);
}
void PerfUnwind::exit(const PerfRecordExit &sample)
@@ -637,7 +645,7 @@ void PerfUnwind::exit(const PerfRecordExit &sample)
QDataStream(&buffer, QIODevice::WriteOnly) << static_cast<quint8>(ThreadEnd)
<< sample.childPid() << sample.childTid()
<< sample.time();
- sendBuffer(buffer);
+ m_auxBuffer.insert(sample.time(), buffer);
}
void PerfUnwind::sendString(qint32 id, const QByteArray& string)
diff --git a/app/perfunwind.h b/app/perfunwind.h
index b5bff8b..34f80e7 100644
--- a/app/perfunwind.h
+++ b/app/perfunwind.h
@@ -34,7 +34,7 @@
#include <QList>
#include <QObject>
#include <QString>
-
+#include <QMap>
#include <limits>
@@ -267,6 +267,7 @@ private:
QString m_kallsymsPath;
bool m_ignoreKallsymsBuildId;
+ QMultiMap<quint64, QByteArray> m_auxBuffer;
QList<PerfRecordSample> m_sampleBuffer;
QList<PerfRecordMmap> m_mmapBuffer;
QHash<qint32, PerfSymbolTable *> m_symbolTables;