summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2020-09-25 13:57:52 +0200
committerMilian Wolff <milian.wolff@kdab.com>2020-09-29 15:43:12 +0000
commit0d969e8e5354514011aa2fccc08d9f820e892c80 (patch)
tree7a83b94757aef57b1854d226867819307487379c
parent0df1430d9448ef78a927fdb77f2b6b576e282aa6 (diff)
Transmit the number of lost events in the LostDefinition4.14
This allows a more detailed report on the GUI side then. Because the count has a quint64 type, we now use a QVariant to store the task event payload. To reduce the padding overhead, the struct is slightly reordered. Change-Id: I01d16da2ba4d3df9f32d6ae53bcff120355eb2c9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--app/perfdata.h2
-rw-r--r--app/perfunwind.cpp19
-rw-r--r--app/perfunwind.h3
-rw-r--r--tests/auto/perfdata/tst_perfdata.cpp2
4 files changed, 16 insertions, 10 deletions
diff --git a/app/perfdata.h b/app/perfdata.h
index 6b2d913..a2946bb 100644
--- a/app/perfdata.h
+++ b/app/perfdata.h
@@ -454,6 +454,8 @@ class PerfRecordLost : public PerfRecord {
public:
PerfRecordLost(PerfEventHeader *header = nullptr, quint64 sampleType = 0,
bool sampleIdAll = false);
+
+ quint64 lost() const { return m_lost; }
private:
quint64 m_id;
quint64 m_lost;
diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp
index 3760613..b79f873 100644
--- a/app/perfunwind.cpp
+++ b/app/perfunwind.cpp
@@ -218,7 +218,7 @@ void PerfUnwind::comm(const PerfRecordComm &comm)
const qint32 commId = resolveString(comm.comm());
bufferEvent(TaskEvent{comm.pid(), comm.tid(), comm.time(), comm.cpu(),
- commId, Command},
+ Command, commId},
&m_taskEventsBuffer, &m_stats.numTaskEventsInRound);
}
@@ -294,7 +294,7 @@ void PerfUnwind::sendEventFormat(qint32 id, const EventFormat &format)
void PerfUnwind::lost(const PerfRecordLost &lost)
{
bufferEvent(TaskEvent{lost.pid(), lost.tid(), lost.time(), lost.cpu(),
- 0, LostDefinition},
+ LostDefinition, lost.lost()},
&m_taskEventsBuffer, &m_stats.numTaskEventsInRound);
}
@@ -684,14 +684,14 @@ void PerfUnwind::analyze(const PerfRecordSample &sample)
void PerfUnwind::fork(const PerfRecordFork &sample)
{
bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), sample.cpu(),
- sample.parentPid(), ThreadStart},
+ ThreadStart, sample.parentPid()},
&m_taskEventsBuffer, &m_stats.numTaskEventsInRound);
}
void PerfUnwind::exit(const PerfRecordExit &sample)
{
bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), sample.cpu(),
- 0, ThreadEnd},
+ ThreadEnd, {}},
&m_taskEventsBuffer, &m_stats.numTaskEventsInRound);
}
@@ -950,7 +950,7 @@ void PerfUnwind::flushEventBuffer(uint desiredBufferSize)
if (taskEventIt->m_type == ThreadStart && taskEventIt->m_pid != taskEventIt->m_payload) {
forwardMmapBuffer(mmapIt, mmapEnd, taskEventIt->time());
const auto childPid = taskEventIt->m_pid;
- const auto parentPid = taskEventIt->m_payload;
+ const auto parentPid = taskEventIt->m_payload.value<qint32>();
symbolTable(childPid)->initAfterFork(symbolTable(parentPid));
} else if (taskEventIt->m_type == ThreadEnd && taskEventIt->m_pid == taskEventIt->m_tid) {
delete m_symbolTables.take(taskEventIt->m_pid);
@@ -1025,7 +1025,8 @@ void PerfUnwind::contextSwitch(const PerfRecordContextSwitch& contextSwitch)
{
bufferEvent(TaskEvent{contextSwitch.pid(), contextSwitch.tid(),
contextSwitch.time(), contextSwitch.cpu(),
- contextSwitch.misc() & PERF_RECORD_MISC_SWITCH_OUT, ContextSwitchDefinition},
+ ContextSwitchDefinition,
+ static_cast<bool>(contextSwitch.misc() & PERF_RECORD_MISC_SWITCH_OUT)},
&m_taskEventsBuffer, &m_stats.numTaskEventsInRound);
}
@@ -1038,9 +1039,11 @@ void PerfUnwind::sendTaskEvent(const TaskEvent& taskEvent)
<< taskEvent.m_time << taskEvent.m_cpu;
if (taskEvent.m_type == ContextSwitchDefinition)
- stream << static_cast<bool>(taskEvent.m_payload);
+ stream << taskEvent.m_payload.value<bool>();
else if (taskEvent.m_type == Command || taskEvent.m_type == ThreadStart)
- stream << taskEvent.m_payload;
+ stream << taskEvent.m_payload.value<qint32>();
+ else if (taskEvent.m_type == LostDefinition)
+ stream << taskEvent.m_payload.value<quint64>();
sendBuffer(buffer);
}
diff --git a/app/perfunwind.h b/app/perfunwind.h
index 5e5a0b1..0792baf 100644
--- a/app/perfunwind.h
+++ b/app/perfunwind.h
@@ -36,6 +36,7 @@
#include <QObject>
#include <QString>
#include <QMap>
+#include <QVariant>
#include <limits>
@@ -280,8 +281,8 @@ private:
qint32 m_tid;
quint64 m_time;
quint32 m_cpu;
- qint32 m_payload;
EventType m_type;
+ QVariant m_payload;
quint64 time() const { return m_time; }
quint64 size() const { return sizeof(TaskEvent); }
diff --git a/tests/auto/perfdata/tst_perfdata.cpp b/tests/auto/perfdata/tst_perfdata.cpp
index 208b3ba..5ba08c1 100644
--- a/tests/auto/perfdata/tst_perfdata.cpp
+++ b/tests/auto/perfdata/tst_perfdata.cpp
@@ -156,7 +156,7 @@ void TestPerfData::testTracingData()
QCOMPARE(stats.numBufferFlushes, flushes);
QCOMPARE(stats.numTimeViolatingSamples, 0u);
QCOMPARE(stats.numTimeViolatingMmaps, 0u);
- QCOMPARE(stats.maxBufferSize, 15584u);
+ QCOMPARE(stats.maxBufferSize, 15608u);
QCOMPARE(stats.maxTime, maxTime);
return;
}