Skip to content

Commit 014cf73

Browse files
Write out compressed and uncompressed packet sizes
1 parent 67e4cb9 commit 014cf73

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/filewriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ buffer file_writer::compress_chunk(buffer& uncompressed)
258258
uint64_t header[2] = { was_written, was_read }; // store compressed and uncompressed sizes
259259
memcpy(compressed.data(), header, header_size); // use memcpy to avoid aliasing issues
260260
compressed.shrink(was_written + header_size);
261+
compressed_sizes.push_back(was_written);
262+
uncompressed_sizes.push_back(was_read);
261263
DLOG3("Filewriter thread %d handing over compressed buffer of %lu bytes, was %lu bytes uncompressed", mTid, (unsigned long)(was_written + header_size), (unsigned long)was_read);
262264
return compressed;
263265
}

src/filewriter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ class file_writer
196196
chunk_mutex.unlock();
197197
}
198198

199+
protected:
200+
// these only written to by worker thread until the end when they are read out
201+
std::vector<uint64_t> compressed_sizes;
202+
std::vector<uint64_t> uncompressed_sizes;
203+
199204
public:
200205
/// Stop sending packets to compression, useful if you want to keep pointers to written memory to keep working
201206
inline void freeze() { if (!holding) holding = true; }

src/write.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ lava_file_writer::~lava_file_writer()
9090
v["frames"].append(k);
9191
highest = std::max(highest, frame.global_frame);
9292
}
93+
v["uncompressed_sizes"] = Json::arrayValue;
94+
v["compressed_sizes"] = Json::arrayValue;
95+
for (const auto i : uncompressed_sizes) v["uncompressed_sizes"].append((Json::Value::UInt64)i);
96+
for (const auto i : compressed_sizes) v["compressed_sizes"].append((Json::Value::UInt64)i);
9397
DLOG("Wrapping up thread %u with %d frames", current.thread, highest);
9498
v["highest_global_frame"] = highest;
9599
const std::string path = mPath + "/frames_" + _to_string(current.thread) + ".json";

0 commit comments

Comments
 (0)