summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2017-03-28 11:55:58 +0200
committerMilian Wolff <milian.wolff@kdab.com>2017-03-29 14:52:40 +0000
commita8ef632713b15a1d11a71b2eca3637e8d604c370 (patch)
tree3b48df58d080f7dc43e8b1accfc9f3c4eb725e2b
parenta374c21359bee141f1635c7798b085cf8e7c516b (diff)
Handle FINISHED_ROUND events
This silences the warnings on the command line: unhandled event type 68 Additionally, these events are used to compute some more statistic values that are useful as a baseline for values we can use in future heuristics: ~~~~~~~~~~ samples: 20993 mmaps: 24331 rounds: 347 max samples per round: 311 max mmaps per round: 781 max buffer size: 1057128 max total event size per round: 2632552 max time: 629013777317625 max time between rounds: 453996043 max reorder time: 375052737 ~~~~~~~~~~ Change-Id: I7e087410ee5551ce66d2bcee223ec57530bcf58d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--app/perfdata.cpp9
-rw-r--r--app/perfdata.h2
-rw-r--r--app/perfunwind.cpp35
-rw-r--r--app/perfunwind.h19
4 files changed, 61 insertions, 4 deletions
diff --git a/app/perfdata.cpp b/app/perfdata.cpp
index fefd34e..8ac226f 100644
--- a/app/perfdata.cpp
+++ b/app/perfdata.cpp
@@ -132,6 +132,15 @@ PerfData::ReadStatus PerfData::processEvents(QDataStream &stream)
m_destination->exit(exit);
break;
}
+ case PERF_RECORD_FINISHED_ROUND: {
+ m_destination->finishedRound();
+ if (contentSize != 0) {
+ qWarning() << "FINISHED_ROUND with non-zero content size detected"
+ << contentSize;
+ stream.skipRawData(contentSize);
+ }
+ break;
+ }
default:
qWarning() << "unhandled event type" << m_eventHeader.type;
diff --git a/app/perfdata.h b/app/perfdata.h
index afc8c71..906def1 100644
--- a/app/perfdata.h
+++ b/app/perfdata.h
@@ -268,6 +268,7 @@ public:
quint32 tid() const { return m_sampleId.tid(); }
quint64 time() const { return m_sampleId.time(); }
quint64 id() const { return m_sampleId.id(); }
+ uint size() const { return m_header.size; }
protected:
PerfRecord(const PerfEventHeader *header, quint64 sampleType, bool sampleIdAll);
@@ -372,7 +373,6 @@ public:
quint64 ip() const { return m_ip; }
const QByteArray &userStack() const { return m_userStack; }
const QList<quint64> &callchain() const { return m_callchain; }
- uint size() const { return m_header.size; }
private:
struct ReadFormat {
diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp
index 006df5e..af4fc9d 100644
--- a/app/perfunwind.cpp
+++ b/app/perfunwind.cpp
@@ -52,6 +52,24 @@ void PerfUnwind::Stats::addEventTime(quint64 time)
maxTime = time;
}
+void PerfUnwind::Stats::finishedRound()
+{
+ maxSamplesPerRound = std::max(maxSamplesPerRound, numSamplesInRound);
+ maxMmapsPerRound = std::max(maxMmapsPerRound, numMmapsInRound);
+ numSamplesInRound = 0;
+ numMmapsInRound = 0;
+ ++numRounds;
+
+ maxTotalEventSizePerRound = std::max(maxTotalEventSizePerRound,
+ totalEventSizePerRound);
+ totalEventSizePerRound = 0;
+
+ if (lastRoundTime > 0)
+ maxTimeBetweenRounds = std::max(maxTimeBetweenRounds, maxTime - lastRoundTime);
+
+ lastRoundTime = maxTime;
+}
+
PerfUnwind::PerfUnwind(QIODevice *output, const QString &systemRoot, const QString &debugPath,
const QString &extraLibsPath, const QString &appPath,
const QString &kallsymsPath, bool printStats) :
@@ -83,6 +101,8 @@ PerfUnwind::PerfUnwind(QIODevice *output, const QString &systemRoot, const QStri
PerfUnwind::~PerfUnwind()
{
+ finishedRound();
+
foreach (const PerfRecordSample &sample, m_sampleBuffer)
analyze(sample);
@@ -93,8 +113,13 @@ PerfUnwind::~PerfUnwind()
QTextStream out(m_output);
out << "samples: " << m_stats.numSamples << "\n";
out << "mmaps: " << m_stats.numMmaps << "\n";
+ out << "rounds: " << m_stats.numRounds << "\n";
+ out << "max samples per round: " << m_stats.maxSamplesPerRound << "\n";
+ out << "max mmaps per round: " << m_stats.maxMmapsPerRound << "\n";
out << "max buffer size: " << m_stats.maxBufferSize << "\n";
+ out << "max total event size per round: " << m_stats.maxTotalEventSizePerRound << "\n";
out << "max time: " << m_stats.maxTime << "\n";
+ out << "max time between rounds: " << m_stats.maxTimeBetweenRounds << "\n";
out << "max reorder time: " << m_stats.maxReorderTime << "\n";
}
}
@@ -115,7 +140,9 @@ Dwfl *PerfUnwind::dwfl(quint32 pid, quint64 timestamp)
void PerfUnwind::registerElf(const PerfRecordMmap &mmap)
{
if (m_stats.enabled) {
+ m_stats.totalEventSizePerRound += mmap.size();
m_stats.addEventTime(mmap.time());
+ ++m_stats.numMmapsInRound;
++m_stats.numMmaps;
return;
}
@@ -343,7 +370,9 @@ void PerfUnwind::sample(const PerfRecordSample &sample)
if (m_stats.enabled) {
m_stats.maxBufferSize = std::max(m_sampleBufferSize, m_stats.maxBufferSize);
+ m_stats.totalEventSizePerRound += sample.size();
m_stats.addEventTime(sample.time());
+ ++m_stats.numSamplesInRound;
++m_stats.numSamples;
// don't return early, stats should include our buffer behavior
}
@@ -480,3 +509,9 @@ PerfKallsymEntry PerfUnwind::findKallsymEntry(quint64 address) const
{
return m_kallsyms.findEntry(address);
}
+
+void PerfUnwind::finishedRound()
+{
+ if (m_stats.enabled)
+ m_stats.finishedRound();
+}
diff --git a/app/perfunwind.h b/app/perfunwind.h
index b1e5599..b077ec8 100644
--- a/app/perfunwind.h
+++ b/app/perfunwind.h
@@ -118,6 +118,7 @@ public:
void attr(const PerfRecordAttr &attr);
void lost(const PerfRecordLost &lost);
void features(const PerfFeatures &features);
+ void finishedRound();
Dwfl_Module *reportElf(quint64 ip, quint32 pid, quint64 timestamp);
bool ipIsInKernelSpace(quint64 ip) const;
@@ -194,9 +195,12 @@ private:
struct Stats
{
Stats()
- : numSamples(0), numMmaps(0),
- maxBufferSize(0),
- maxTime(0), maxReorderTime(0),
+ : numSamples(0), numMmaps(0), numRounds(0),
+ numSamplesInRound(0), numMmapsInRound(0),
+ maxSamplesPerRound(0), maxMmapsPerRound(0),
+ maxBufferSize(0), maxTotalEventSizePerRound(0),
+ maxTime(0), maxTimeBetweenRounds(0), maxReorderTime(0),
+ lastRoundTime(0), totalEventSizePerRound(0),
enabled(false)
{}
@@ -205,9 +209,18 @@ private:
quint64 numSamples;
quint64 numMmaps;
+ quint64 numRounds;
+ int numSamplesInRound;
+ int numMmapsInRound;
+ int maxSamplesPerRound;
+ int maxMmapsPerRound;
uint maxBufferSize;
+ uint maxTotalEventSizePerRound;
quint64 maxTime;
+ quint64 maxTimeBetweenRounds;
quint64 maxReorderTime;
+ quint64 lastRoundTime;
+ uint totalEventSizePerRound;
bool enabled;
};
Stats m_stats;