Commit b8a71974 authored by Milian Wolff's avatar Milian Wolff
Browse files

Convert more data types to signed integers.

We now also calculate the difference between time, peakRSS and
system info when diffing heaptrack data files.
parent 35df75db
......@@ -140,7 +140,7 @@ bool AccumulatedTraceData::read(const string& inputFile)
bool AccumulatedTraceData::read(istream& in)
{
LineReader reader;
uint64_t timeStamp = 0;
int64_t timeStamp = 0;
vector<string> opNewStrings = {
// 64 bit
......@@ -295,15 +295,7 @@ bool AccumulatedTraceData::read(istream& in)
const auto& info = allocationInfos[allocationInfoIndex.index];
auto& allocation = findAllocation(info.traceIndex);
if (!allocation.allocations || static_cast<uint64_t>(allocation.leaked) < info.size) {
if (!fromAttached) {
cerr << "inconsistent allocation info, underflowed allocations of " << info.traceIndex << endl;
}
allocation.leaked = 0;
allocation.allocations = 0;
} else {
allocation.leaked -= info.size;
}
allocation.leaked -= info.size;
totalCost.leaked -= info.size;
if (temporary) {
++allocation.temporary;
......@@ -323,7 +315,7 @@ bool AccumulatedTraceData::read(istream& in)
// comment or empty line
continue;
} else if (reader.mode() == 'c') {
uint64_t newStamp = 0;
int64_t newStamp = 0;
if (!(reader >> newStamp)) {
cerr << "Failed to read time stamp: " << reader.line() << endl;
continue;
......@@ -331,7 +323,7 @@ bool AccumulatedTraceData::read(istream& in)
handleTimeStamp(timeStamp, newStamp);
timeStamp = newStamp;
} else if (reader.mode() == 'R') { // RSS timestamp
uint64_t rss = 0;
int64_t rss = 0;
reader >> rss;
if (rss > peakRSS) {
peakRSS = rss;
......@@ -466,6 +458,10 @@ POTENTIALLY_UNUSED void printTrace(const AccumulatedTraceData& data, TraceIndex
void AccumulatedTraceData::diff(const AccumulatedTraceData& base)
{
totalCost -= base.totalCost;
totalTime -= base.totalTime;
peakRSS -= base.peakRSS;
systemInfo.pages -= base.systemInfo.pages;
systemInfo.pageSize -= base.systemInfo.pageSize;
// step 0: remap strings and ips
const auto& stringMap = remapStrings(strings, base.strings);
......
......@@ -84,7 +84,7 @@ struct AccumulatedTraceData
AccumulatedTraceData();
virtual ~AccumulatedTraceData() = default;
virtual void handleTimeStamp(uint64_t oldStamp, uint64_t newStamp) = 0;
virtual void handleTimeStamp(int64_t oldStamp, int64_t newStamp) = 0;
virtual void handleAllocation(const AllocationInfo& info, const AllocationIndex index) = 0;
virtual void handleDebuggee(const char* command) = 0;
......@@ -102,13 +102,13 @@ struct AccumulatedTraceData
std::vector<Allocation> allocations;
AllocationData totalCost;
uint64_t totalTime = 0;
uint64_t peakTime = 0;
uint64_t peakRSS = 0;
int64_t totalTime = 0;
int64_t peakTime = 0;
int64_t peakRSS = 0;
struct SystemInfo {
uint64_t pages = 0;
uint64_t pageSize = 0;
int64_t pages = 0;
int64_t pageSize = 0;
};
SystemInfo systemInfo;
......
......@@ -33,7 +33,8 @@ struct ChartRows
enum {
MAX_NUM_COST = 20
};
quint64 timeStamp = 0;
// time in ms
qint64 timeStamp = 0;
std::array<qint64, MAX_NUM_COST> cost;
};
Q_DECLARE_TYPEINFO(ChartRows, Q_MOVABLE_TYPE);
......
......@@ -189,13 +189,13 @@ struct ParserData final : public AccumulatedTraceData
findTopChartEntries(&ChartMergeData::temporary, &LabelIds::temporary, &temporaryChartData);
}
void handleTimeStamp(uint64_t /*oldStamp*/, uint64_t newStamp)
void handleTimeStamp(int64_t /*oldStamp*/, int64_t newStamp)
{
if (!buildCharts) {
return;
}
maxConsumedSinceLastTimeStamp = max(maxConsumedSinceLastTimeStamp, totalCost.leaked);
const uint64_t diffBetweenTimeStamps = totalTime / MAX_CHART_DATAPOINTS;
const int64_t diffBetweenTimeStamps = totalTime / MAX_CHART_DATAPOINTS;
if (newStamp != totalTime && newStamp - lastTimeStamp < diffBetweenTimeStamps) {
return;
}
......@@ -204,7 +204,7 @@ struct ParserData final : public AccumulatedTraceData
lastTimeStamp = newStamp;
// create the rows
auto createRow = [] (uint64_t timeStamp, int64_t totalCost) {
auto createRow = [] (int64_t timeStamp, int64_t totalCost) {
ChartRows row;
row.timeStamp = timeStamp;
row.cost[0] = totalCost;
......@@ -289,7 +289,7 @@ struct ParserData final : public AccumulatedTraceData
};
QHash<IpIndex, LabelIds> labelIds;
int64_t maxConsumedSinceLastTimeStamp = 0;
uint64_t lastTimeStamp = 0;
int64_t lastTimeStamp = 0;
StringCache stringCache;
......
......@@ -28,10 +28,10 @@ struct SummaryData
{
QString debuggee;
AllocationData cost;
uint64_t totalTime;
uint64_t peakTime;
uint64_t peakRSS;
uint64_t totalSystemMemory;
int64_t totalTime;
int64_t peakTime;
int64_t peakRSS;
int64_t totalSystemMemory;
};
Q_DECLARE_METATYPE(SummaryData);
......
......@@ -150,28 +150,28 @@ QVariant TreeModel::data(const QModelIndex& index, int role) const
switch (static_cast<Columns>(index.column())) {
case AllocatedColumn:
if (role == SortRole || role == MaxCostRole) {
return static_cast<quint64>(abs(row->cost.allocated));
return static_cast<qint64>(abs(row->cost.allocated));
}
return m_format.formatByteSize(row->cost.allocated);
case AllocationsColumn:
if (role == SortRole || role == MaxCostRole) {
return static_cast<quint64>(abs(row->cost.allocations));
return static_cast<qint64>(abs(row->cost.allocations));
}
return static_cast<qint64>(row->cost.allocations);
case TemporaryColumn:
if (role == SortRole || role == MaxCostRole) {
return static_cast<quint64>(abs(row->cost.temporary));
return static_cast<qint64>(abs(row->cost.temporary));
}
return static_cast<qint64>(row->cost.temporary);
case PeakColumn:
if (role == SortRole || role == MaxCostRole) {
return static_cast<quint64>(abs(row->cost.peak));
return static_cast<qint64>(abs(row->cost.peak));
} else {
return m_format.formatByteSize(row->cost.peak);
}
case LeakedColumn:
if (role == SortRole || role == MaxCostRole) {
return static_cast<quint64>(abs(row->cost.leaked));
return static_cast<qint64>(abs(row->cost.leaked));
} else {
return m_format.formatByteSize(row->cost.leaked);
}
......
......@@ -457,7 +457,7 @@ struct Printer final : public AccumulatedTraceData
}
}
void handleTimeStamp(uint64_t /*oldStamp*/, uint64_t newStamp) override
void handleTimeStamp(int64_t /*oldStamp*/, int64_t newStamp) override
{
if (massifOut.is_open()) {
writeMassifSnapshot(newStamp, newStamp == totalTime);
......
......@@ -93,6 +93,11 @@ public:
return true;
}
bool operator>>(int64_t& hex)
{
return readHex(hex);
}
bool operator>>(uint64_t& hex)
{
return readHex(hex);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment