Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse tracepoint data in hotspot #687

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 59 additions & 5 deletions src/parsers/perf/perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ struct Sample : Record
QVector<qint32> frames;
quint8 guessedFrames = 0;
QVector<SampleCost> costs;
quint32 tracePointFormat = std::numeric_limits<quint32>::max();
quint32 tracePointData = std::numeric_limits<quint32>::max();
};

QDataStream& operator>>(QDataStream& stream, Sample& sample)
Expand Down Expand Up @@ -539,6 +541,43 @@ QDebug operator<<(QDebug stream, const Error& error)
return stream;
}

struct TracePointFormat
{
StringId systemId;
StringId nameId;
quint32 flags = 0;
StringId format;
};

QDataStream& operator>>(QDataStream& stream, TracePointFormat& format)
{
stream >> format.systemId >> format.nameId >> format.flags >> format.format;
return stream;
}

QDebug operator<<(QDebug stream, TracePointFormat format)
{
stream.noquote().nospace() << "TracePointFormat{"
<< "systemId=" << format.systemId << ", "
<< "nameId=" << format.nameId << ", "
<< "flags=" << format.flags << ", "
<< "format=" << format.format << "}";
return stream;
}

using TracePointData = QHash<qint32, QVariant>;

QDebug operator<<(QDebug stream, const TracePointData& traceData)
{
auto s = stream.noquote().nospace();
s << "TracePointData{";
for (auto it = traceData.cbegin(), end = traceData.cend(); it != end; it++) {
s << it.key() << "=" << it.value() << ", ";
}
s << "}";
return stream;
}

void addCallerCalleeEvent(const Data::Symbol& symbol, const Data::Location& location, int type, quint64 cost,
QSet<Data::Symbol>* recursionGuard, Data::CallerCalleeResults* callerCalleeResult,
int numCosts)
Expand Down Expand Up @@ -760,11 +799,19 @@ class PerfParserPrivate : public QObject
}
}

if (static_cast<EventType>(eventType) == EventType::TracePointSample) {
quint32 eventFormatId;
TracePointData traceData;
stream >> eventFormatId >> traceData;
tracepointData[eventFormatId].push_back(traceData);
qCDebug(LOG_PERFPARSER) << "parsed:" << traceData;
sample.tracePointFormat = eventFormatId;
sample.tracePointData = tracepointData.size() - 1;
}

addRecord(sample);
addSample(sample);

if (static_cast<EventType>(eventType) == EventType::TracePointSample)
return true; // TODO: read full data
break;
}
case EventType::ThreadStart: {
Expand Down Expand Up @@ -876,9 +923,14 @@ class PerfParserPrivate : public QObject
emit debugInfoDownloadProgress(strings.value(module.id), strings.value(url.id), numerator, denominator);
break;
}
case EventType::TracePointFormat:
// TODO: implement me
return true;
case EventType::TracePointFormat: {
qint32 id;
TracePointFormat format;
stream >> id >> format;
qCDebug(LOG_PERFPARSER) << "parsed:" << format;
tracepointFormat[id] = format;
break;
}
case EventType::InvalidType:
break;
}
Expand Down Expand Up @@ -1435,6 +1487,8 @@ class PerfParserPrivate : public QObject
QHash<quint32, quint64> m_lastSampleTimePerCore;
Settings::CostAggregation costAggregation;
bool perfMapFileExists = false;
QHash<quint32, TracePointFormat> tracepointFormat;
QHash<quint32, QVector<TracePointData>> tracepointData;

// samples recorded without --call-graph have only one frame
int m_numSamplesWithMoreThanOneFrame = 0;
Expand Down
Loading