aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perfprofiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-05-03 09:51:07 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-05-08 09:27:22 +0000
commit61fb66ab539c419afc092670bfffe60291b2a933 (patch)
tree81d101df8d7d43069a0b1d9c7589f9757f511a03 /src/plugins/perfprofiler
parentc770d3f4a760fdd1ce6aaeb02efb617e7a21a24e (diff)
PerfProfiler: Remove backwards compatibility support
Define a new file extension, new file magic, and remove support for the old data format. You won't be able to load traces generated with older Qt Creators in 4.10 anymore and you won't be able to use older perfparsers with Qt Creator 4.10. On the flip side, we can move along more quickly now and integrate features from KDAB's perfparser. This is to be preferred because the maintenance of two different perfparsers is quite a burden. Change-Id: I69918eadc3294abfbb0b809a54c3c9f25405409a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r--src/plugins/perfprofiler/perfevent.h49
-rw-r--r--src/plugins/perfprofiler/perfeventtype.h20
-rw-r--r--src/plugins/perfprofiler/perfprofilerconstants.h3
-rw-r--r--src/plugins/perfprofiler/perfprofilertool.cpp8
-rw-r--r--src/plugins/perfprofiler/perfprofilertracefile.cpp191
-rw-r--r--src/plugins/perfprofiler/perfprofilertracefile.h1
-rw-r--r--src/plugins/perfprofiler/perfprofilertracemanager.cpp2
-rw-r--r--src/plugins/perfprofiler/perftimelinemodel.cpp9
-rw-r--r--src/plugins/perfprofiler/perftimelinemodel.h2
9 files changed, 114 insertions, 171 deletions
diff --git a/src/plugins/perfprofiler/perfevent.h b/src/plugins/perfprofiler/perfevent.h
index 3bea1c3bd3f..8ca64e15a93 100644
--- a/src/plugins/perfprofiler/perfevent.h
+++ b/src/plugins/perfprofiler/perfevent.h
@@ -69,7 +69,6 @@ public:
void setNumGuessedFrames(quint8 numGuessedFrames) { m_numGuessedFrames = numGuessedFrames; }
quint64 period() const { return m_value; }
- quint64 weight() const { return m_weight; }
quint64 value() const { return m_value; }
quint8 feature() const { return m_feature; }
@@ -87,7 +86,6 @@ private:
quint32 m_pid = 0;
quint32 m_tid = 0;
quint64 m_value = 0;
- quint64 m_weight = 0;
quint8 m_origNumGuessedFrames = 0;
quint8 m_numGuessedFrames = 0;
quint8 m_feature = PerfEventType::InvalidFeature;
@@ -101,7 +99,6 @@ inline QDataStream &operator>>(QDataStream &stream, PerfEvent &event)
case PerfEventType::Command:
case PerfEventType::LocationDefinition:
case PerfEventType::SymbolDefinition:
- case PerfEventType::AttributesDefinition49:
case PerfEventType::AttributesDefinition:
case PerfEventType::StringDefinition:
case PerfEventType::FeaturesDefinition:
@@ -112,8 +109,6 @@ inline QDataStream &operator>>(QDataStream &stream, PerfEvent &event)
case PerfEventType::ThreadStart:
case PerfEventType::ThreadEnd:
case PerfEventType::LostDefinition:
- case PerfEventType::Sample43:
- case PerfEventType::Sample49:
case PerfEventType::Sample:
case PerfEventType::TracePointSample:
case PerfEventType::ContextSwitchDefinition:
@@ -147,21 +142,14 @@ inline QDataStream &operator>>(QDataStream &stream, PerfEvent &event)
default: {
qint32 typeIndex;
stream >> event.m_origFrames >> event.m_origNumGuessedFrames;
- if (event.m_feature == PerfEventType::Sample43 || event.m_feature == PerfEventType::Sample49
- || event.m_feature == PerfEventType::TracePointSample49) {
- stream >> typeIndex;
- if (event.m_feature != PerfEventType::Sample43)
- stream >> event.m_value >> event.m_weight;
+ QVector<QPair<qint32, quint64>> values;
+ stream >> values;
+ if (values.isEmpty()) {
+ typeIndex = 0;
} else {
- QVector<QPair<qint32, quint64>> values;
- stream >> values;
- if (values.isEmpty()) {
- typeIndex = 0;
- } else {
- typeIndex = values.first().first;
- event.m_value = values.first().second;
- // TODO: support multiple values per event.
- }
+ typeIndex = values.first().first;
+ event.m_value = values.first().second;
+ // TODO: support multiple values per event.
}
if (event.m_feature == PerfEventType::TracePointSample)
stream >> event.m_traceData;
@@ -185,29 +173,18 @@ inline QDataStream &operator<<(QDataStream &stream, const PerfEvent &event)
case PerfEventType::ContextSwitchDefinition:
stream << bool(event.extra());
break;
- case PerfEventType::Sample43:
- case PerfEventType::Sample49:
case PerfEventType::Sample:
- case PerfEventType::TracePointSample49:
- case PerfEventType::TracePointSample:
+ case PerfEventType::TracePointSample: {
stream << event.m_origFrames << event.m_origNumGuessedFrames;
- if (feature == PerfEventType::Sample43 || feature == PerfEventType::Sample49 ||
- feature == PerfEventType::TracePointSample49) {
- stream << static_cast<qint32>(PerfEvent::LastSpecialTypeId - event.typeIndex());
- if (feature != PerfEventType::Sample43)
- stream << event.m_value << event.m_weight;
- } else {
- QVector<QPair<qint32, quint64>> values;
- values.push_back({ PerfEvent::LastSpecialTypeId - event.typeIndex(), event.m_value });
- stream << values;
- }
+ QVector<QPair<qint32, quint64>> values;
+ values.push_back({ PerfEvent::LastSpecialTypeId - event.typeIndex(), event.m_value });
+ stream << values;
- if (feature == PerfEventType::TracePointSample
- || feature == PerfEventType::TracePointSample49) {
+ if (feature == PerfEventType::TracePointSample)
stream << event.m_traceData;
- }
break;
+ }
default:
QTC_CHECK(false);
}
diff --git a/src/plugins/perfprofiler/perfeventtype.h b/src/plugins/perfprofiler/perfeventtype.h
index 325e0714aee..245b25991a9 100644
--- a/src/plugins/perfprofiler/perfeventtype.h
+++ b/src/plugins/perfprofiler/perfeventtype.h
@@ -39,21 +39,17 @@ public:
static const qint32 staticClassId = 0x70726674; // 'prft'
enum Feature {
- Sample43, // Only used until QtC/perfparser 4.3
ThreadStart,
ThreadEnd,
Command,
LocationDefinition,
SymbolDefinition,
- AttributesDefinition49,
StringDefinition,
LostDefinition,
FeaturesDefinition,
Error,
- Sample49,
Progress,
TracePointFormat,
- TracePointSample49,
AttributesDefinition,
ContextSwitchDefinition,
Sample,
@@ -63,9 +59,7 @@ public:
static quint64 attributeFeatures()
{
- return (1ull << Sample43) | (1ull << Sample49) | (1ull << Sample)
- | (1ull << TracePointSample49) | (1ull << TracePointSample)
- | (1ull << AttributesDefinition49) | (1ull << AttributesDefinition);
+ return (1ull << Sample) | (1ull << TracePointSample) | (1ull << AttributesDefinition);
}
static quint64 metaFeatures()
@@ -96,8 +90,10 @@ public:
struct Attribute {
quint64 config = std::numeric_limits<quint64>::max();
+ quint64 frequencyOrPeriod = std::numeric_limits<quint64>::max();
quint32 type = std::numeric_limits<quint32>::max();
qint32 name = -1;
+ bool usesFrequency = false;
};
struct Location {
@@ -132,12 +128,8 @@ public:
bool isAttribute() const
{
switch (feature()) {
- case Sample43:
- case Sample49:
case Sample:
- case AttributesDefinition49:
case AttributesDefinition:
- case TracePointSample49:
case TracePointSample:
return true;
default:
@@ -188,12 +180,14 @@ private:
inline QDataStream &operator>>(QDataStream &stream, PerfEventType::Attribute &attribute)
{
- return stream >> attribute.type >> attribute.config >> attribute.name;
+ return stream >> attribute.type >> attribute.config >> attribute.name
+ >> attribute.usesFrequency >> attribute.frequencyOrPeriod;
}
inline QDataStream &operator<<(QDataStream &stream, const PerfEventType::Attribute &attribute)
{
- return stream << attribute.type << attribute.config << attribute.name;
+ return stream << attribute.type << attribute.config << attribute.name
+ << attribute.usesFrequency << attribute.frequencyOrPeriod;
}
inline QDataStream &operator>>(QDataStream &stream, PerfEventType::Location &location)
diff --git a/src/plugins/perfprofiler/perfprofilerconstants.h b/src/plugins/perfprofiler/perfprofilerconstants.h
index b35ba28ec86..32e174cf5d0 100644
--- a/src/plugins/perfprofiler/perfprofilerconstants.h
+++ b/src/plugins/perfprofiler/perfprofilerconstants.h
@@ -66,8 +66,7 @@ const char PerfSampleFrequency[] = "-F";
const char PerfSampleCount[] = "-c";
const char PerfStreamMagic[] = "QPERFSTREAM";
-const char PerfQzfileMagic[] = "QPERFQZFILE";
-const char PerfZqfileMagic[] = "QPERFZQFILE";
+const char PerfZqfileMagic[] = "PTQFILE4.10";
} // namespace Constants
} // namespace PerfProfiler
diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp
index fea4aacb9b2..d719884ccd2 100644
--- a/src/plugins/perfprofiler/perfprofilertool.cpp
+++ b/src/plugins/perfprofiler/perfprofilertool.cpp
@@ -613,7 +613,7 @@ void PerfProfilerTool::showLoadTraceDialog()
QString filename = QFileDialog::getOpenFileName(
ICore::mainWindow(), tr("Load Trace File"),
- "", tr("Trace File (*.ptr)"));
+ "", tr("Trace File (*.ptq)"));
if (filename.isEmpty())
return;
@@ -633,11 +633,11 @@ void PerfProfilerTool::showSaveTraceDialog()
QString filename = QFileDialog::getSaveFileName(
ICore::mainWindow(), tr("Save Trace File"),
- "", tr("Trace File (*.ptr)"));
+ "", tr("Trace File (*.ptq)"));
if (filename.isEmpty())
return;
- if (!filename.endsWith(".ptr"))
- filename += ".ptr";
+ if (!filename.endsWith(".ptq"))
+ filename += ".ptq";
setToolActionsEnabled(false);
m_traceManager->saveToTraceFile(filename);
diff --git a/src/plugins/perfprofiler/perfprofilertracefile.cpp b/src/plugins/perfprofiler/perfprofilertracefile.cpp
index 144fa9800b1..cccdc6f7da0 100644
--- a/src/plugins/perfprofiler/perfprofilertracefile.cpp
+++ b/src/plugins/perfprofiler/perfprofilertracefile.cpp
@@ -33,12 +33,11 @@
namespace PerfProfiler {
namespace Internal {
-Q_STATIC_ASSERT(sizeof(Constants::PerfStreamMagic) == sizeof(Constants::PerfQzfileMagic));
Q_STATIC_ASSERT(sizeof(Constants::PerfStreamMagic) == sizeof(Constants::PerfZqfileMagic));
PerfProfilerTraceFile::PerfProfilerTraceFile(QObject *parent) :
Timeline::TimelineTraceFile(parent), m_messageSize(0),
- m_dataStreamVersion(-1), m_compressed(false), m_mangledPackets(false)
+ m_dataStreamVersion(-1), m_compressed(false)
{
// This should result in either a direct or a queued connection, depending on where the signal
// comes from. readMessages() should always run in the GUI thread.
@@ -166,97 +165,83 @@ void PerfProfilerTraceFile::readMessages(const QByteArray &buffer)
QDataStream dataStream(buffer);
dataStream.setVersion(m_dataStreamVersion);
- while (!dataStream.atEnd()) {
- PerfEvent event;
- dataStream >> event;
-
- const qint64 timestamp = event.timestamp();
- if (timestamp > 0)
- event.setTimestamp(adjustTimestamp(timestamp));
-
- qint32 id = -1;
- switch (event.feature()) {
- case PerfEventType::LocationDefinition: {
- PerfEventType location(PerfEventType::LocationDefinition);
- dataStream >> id >> location;
- traceManager->setEventType(id, std::move(location));
- break;
- }
- case PerfEventType::SymbolDefinition: {
- PerfProfilerTraceManager::Symbol symbol;
- dataStream >> id >> symbol;
- traceManager->setSymbol(id, symbol);
- break;
- }
- case PerfEventType::AttributesDefinition49:
- case PerfEventType::AttributesDefinition: {
- PerfEventType attributes(PerfEventType::AttributesDefinition49);
- dataStream >> id >> attributes;
- if (event.feature() == PerfEventType::AttributesDefinition) {
- bool usesFrequency;
- quint64 frequencyOrPeriod;
- dataStream >> usesFrequency >> frequencyOrPeriod;
- }
- traceManager->setEventType(PerfEvent::LastSpecialTypeId - id, std::move(attributes));
- break;
- }
- case PerfEventType::StringDefinition: {
- QByteArray string;
- dataStream >> id >> string;
- traceManager->setString(id, string);
- break;
- }
- case PerfEventType::FeaturesDefinition: {
- PerfFeatures features;
- dataStream >> features;
- break;
- }
- case PerfEventType::Error: {
- qint32 errorCode;
- QString message;
- dataStream >> errorCode >> message;
- break;
- }
- case PerfEventType::Progress: {
- float progress;
- dataStream >> progress;
- break;
- }
- case PerfEventType::TracePointFormat: {
- PerfProfilerTraceManager::TracePoint tracePoint;
- dataStream >> id >> tracePoint;
- traceManager->setTracePoint(id, tracePoint);
- break;
- }
- case PerfEventType::Command: {
- PerfProfilerTraceManager::Thread thread;
- dataStream >> thread;
- traceManager->setThread(thread.tid, thread);
- break;
- }
- case PerfEventType::ThreadStart:
- case PerfEventType::ThreadEnd:
- case PerfEventType::LostDefinition:
- case PerfEventType::ContextSwitchDefinition:
- if (acceptsSamples())
- traceManager->appendEvent(std::move(event));
- break;
- case PerfEventType::Sample43:
- case PerfEventType::Sample49:
- case PerfEventType::Sample:
- case PerfEventType::TracePointSample49:
- case PerfEventType::TracePointSample:
- if (acceptsSamples())
- traceManager->appendSampleEvent(std::move(event));
- break;
- }
-
- if (!m_mangledPackets) {
- if (!dataStream.atEnd())
- qWarning() << "Read only part of message";
- break;
- }
+ PerfEvent event;
+ dataStream >> event;
+
+ const qint64 timestamp = event.timestamp();
+ if (timestamp > 0)
+ event.setTimestamp(adjustTimestamp(timestamp));
+
+ qint32 id = -1;
+ switch (event.feature()) {
+ case PerfEventType::LocationDefinition: {
+ PerfEventType location(PerfEventType::LocationDefinition);
+ dataStream >> id >> location;
+ traceManager->setEventType(id, std::move(location));
+ break;
+ }
+ case PerfEventType::SymbolDefinition: {
+ PerfProfilerTraceManager::Symbol symbol;
+ dataStream >> id >> symbol;
+ traceManager->setSymbol(id, symbol);
+ break;
+ }
+ case PerfEventType::AttributesDefinition: {
+ PerfEventType attributes(PerfEventType::AttributesDefinition);
+ dataStream >> id >> attributes;
+ traceManager->setEventType(PerfEvent::LastSpecialTypeId - id, std::move(attributes));
+ break;
+ }
+ case PerfEventType::StringDefinition: {
+ QByteArray string;
+ dataStream >> id >> string;
+ traceManager->setString(id, string);
+ break;
+ }
+ case PerfEventType::FeaturesDefinition: {
+ PerfFeatures features;
+ dataStream >> features;
+ break;
+ }
+ case PerfEventType::Error: {
+ qint32 errorCode;
+ QString message;
+ dataStream >> errorCode >> message;
+ break;
}
+ case PerfEventType::Progress: {
+ float progress;
+ dataStream >> progress;
+ break;
+ }
+ case PerfEventType::TracePointFormat: {
+ PerfProfilerTraceManager::TracePoint tracePoint;
+ dataStream >> id >> tracePoint;
+ traceManager->setTracePoint(id, tracePoint);
+ break;
+ }
+ case PerfEventType::Command: {
+ PerfProfilerTraceManager::Thread thread;
+ dataStream >> thread;
+ traceManager->setThread(thread.tid, thread);
+ break;
+ }
+ case PerfEventType::ThreadStart:
+ case PerfEventType::ThreadEnd:
+ case PerfEventType::LostDefinition:
+ case PerfEventType::ContextSwitchDefinition:
+ if (acceptsSamples())
+ traceManager->appendEvent(std::move(event));
+ break;
+ case PerfEventType::Sample:
+ case PerfEventType::TracePointSample:
+ if (acceptsSamples())
+ traceManager->appendSampleEvent(std::move(event));
+ break;
+ }
+
+ if (!dataStream.atEnd())
+ qWarning() << "Read only part of message";
}
void PerfProfilerTraceFile::readFromDevice()
@@ -266,19 +251,18 @@ void PerfProfilerTraceFile::readFromDevice()
if (m_device->bytesAvailable() < magicSize + static_cast<int>(sizeof(qint32)))
return;
- QVarLengthArray<char> magic(magicSize);
+ QByteArray magic(magicSize, 0);
m_device->read(magic.data(), magicSize);
if (strncmp(magic.data(), Constants::PerfStreamMagic, magicSize) == 0) {
m_compressed = false;
- m_mangledPackets = false;
- } else if (strncmp(magic.data(), Constants::PerfQzfileMagic, magicSize) == 0) {
- m_compressed = true;
- m_mangledPackets = true;
} else if (strncmp(magic.data(), Constants::PerfZqfileMagic, magicSize) == 0) {
m_compressed = true;
- m_mangledPackets = false;
} else {
- fail(tr("Invalid data format"));
+ fail(tr("Invalid data format. The trace file's identification string is \"%1\"."
+ "An acceptable trace file should have \"%2\". You cannot read trace files "
+ "generated with older versions of Qt Creator.")
+ .arg(QString::fromLatin1(magic))
+ .arg(QString::fromLatin1(Constants::PerfZqfileMagic)));
return;
}
@@ -287,7 +271,10 @@ void PerfProfilerTraceFile::readFromDevice()
if (m_dataStreamVersion < 0
|| m_dataStreamVersion > QDataStream::Qt_DefaultCompiledVersion) {
- fail(tr("Invalid data format"));
+ fail(tr("Invalid data format. The trace file was written with data stream version %1. "
+ "We can read at most version %2. Please use a newer version of Qt.")
+ .arg(m_dataStreamVersion)
+ .arg(qint32(QDataStream::Qt_DefaultCompiledVersion)));
return;
}
}
@@ -305,8 +292,6 @@ void PerfProfilerTraceFile::readFromDevice()
m_messageSize = 0;
if (!m_compressed)
emit messagesAvailable(buffer);
- else if (m_mangledPackets)
- emit messagesAvailable(qUncompress(buffer));
else
emit blockAvailable(qUncompress(buffer));
@@ -460,7 +445,7 @@ void PerfProfilerTraceFile::writeToDevice()
{
CompressedDataStream bufferStream(m_device.data());
- const quint8 feature = PerfEventType::AttributesDefinition49;
+ const quint8 feature = PerfEventType::AttributesDefinition;
qint32 id = 0;
for (const PerfEventType &attribute : traceManager->attributes()) {
if (!attribute.isAttribute())
diff --git a/src/plugins/perfprofiler/perfprofilertracefile.h b/src/plugins/perfprofiler/perfprofilertracefile.h
index ac58cfe168c..756ba2902d7 100644
--- a/src/plugins/perfprofiler/perfprofilertracefile.h
+++ b/src/plugins/perfprofiler/perfprofilertracefile.h
@@ -71,7 +71,6 @@ protected:
quint32 m_messageSize;
qint32 m_dataStreamVersion;
bool m_compressed;
- bool m_mangledPackets;
};
} // namespace Internal
diff --git a/src/plugins/perfprofiler/perfprofilertracemanager.cpp b/src/plugins/perfprofiler/perfprofilertracemanager.cpp
index 4f3b4d5c058..13814447e4f 100644
--- a/src/plugins/perfprofiler/perfprofilertracemanager.cpp
+++ b/src/plugins/perfprofiler/perfprofilertracemanager.cpp
@@ -179,7 +179,7 @@ void PerfProfilerTraceManager::clearTypeStorage()
const Timeline::TraceEventType &PerfProfilerEventTypeStorage::get(int typeId) const
{
- static const PerfEventType emptyAttribute(PerfEventType::AttributesDefinition49);
+ static const PerfEventType emptyAttribute(PerfEventType::AttributesDefinition);
static const PerfEventType emptyLocation(PerfEventType::LocationDefinition);
if (typeId >= 0) {
diff --git a/src/plugins/perfprofiler/perftimelinemodel.cpp b/src/plugins/perfprofiler/perftimelinemodel.cpp
index b3e747c21d8..0ab45a2963b 100644
--- a/src/plugins/perfprofiler/perftimelinemodel.cpp
+++ b/src/plugins/perfprofiler/perftimelinemodel.cpp
@@ -167,8 +167,6 @@ QVariantMap PerfTimelineModel::details(int index) const
const int guessedFrames = -frame.numSamples;
if (guessedFrames > 0)
result.insert(tr("Guessed"), tr("%n frames", nullptr, guessedFrames));
- if (const int sampleWeight = weight(index))
- result.insert(tr("Weight"), sampleWeight);
if (const int sampleValue = value(index))
result.insert(tr("Value"), sampleValue);
if (attribute.type == PerfEventType::TypeTracepoint) {
@@ -406,13 +404,11 @@ void PerfTimelineModel::addSample(const PerfEvent &event, qint64 resourceDelta,
{
static const int intMax = std::numeric_limits<int>::max();
const int value = static_cast<int>(qMin(static_cast<quint64>(intMax), event.value()));
- const int weight = static_cast<int>(qMin(static_cast<quint64>(intMax), event.weight()));
const int id = TimelineModel::insert(event.timestamp(), 1, event.typeIndex());
StackFrame sample = StackFrame::sampleFrame();
sample.numSamples = event.numGuessedFrames() > 0 ? -event.numGuessedFrames() : 1;
sample.value = value;
- sample.weight = weight;
sample.resourcePeak = m_resourceBlocks.currentTotal();
sample.resourceDelta = resourceDelta;
sample.resourceGuesses = resourceGuesses;
@@ -617,11 +613,6 @@ int PerfTimelineModel::value(int index) const
return m_data[index].value;
}
-int PerfTimelineModel::weight(int index) const
-{
- return m_data[index].weight;
-}
-
bool PerfTimelineModel::handlesTypeId(int typeId) const
{
return m_locationStats.contains(typeId);
diff --git a/src/plugins/perfprofiler/perftimelinemodel.h b/src/plugins/perfprofiler/perftimelinemodel.h
index b25bcbb2d99..ea429de00c9 100644
--- a/src/plugins/perfprofiler/perftimelinemodel.h
+++ b/src/plugins/perfprofiler/perftimelinemodel.h
@@ -89,7 +89,6 @@ public:
}
int value(int index) const;
- int weight(int index) const;
QHash<qint32, QVariant> extraData(int index) const { return m_extraData.value(index); }
@@ -106,7 +105,6 @@ private:
int displayRowCollapsed = MaximumSpecialRow;
int displayRowExpanded = MaximumSpecialRow;
int value = 0;
- int weight = 0;
qint64 resourcePeak = 0;
qint64 resourceDelta = 0;