Skip to content

Commit

Permalink
[memprof] Omit the key length for the call stack table (#89510)
Browse files Browse the repository at this point in the history
The call stack table has a constant key length, so we don't need to
serialize or deserialize it for every key-data pair.  Omitting the key
length saves 0.64% of the indexed MemProf file size.

Note that it's OK to change the format because Version2 is still under
development.
  • Loading branch information
kazutakahirata committed Apr 21, 2024
1 parent 37fe3c6 commit de1d4eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/ProfileData/MemProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,8 @@ class CallStackWriterTrait {
EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {
using namespace support;
endian::Writer LE(Out, llvm::endianness::little);
// We do not explicitly emit the key length because it is a constant.
offset_type N = sizeof(K);
LE.write<offset_type>(N);
offset_type M = sizeof(FrameId) * V.size();
LE.write<offset_type>(M);
return std::make_pair(N, M);
Expand Down Expand Up @@ -697,8 +697,8 @@ class CallStackLookupTrait {
ReadKeyDataLength(const unsigned char *&D) {
using namespace support;

offset_type KeyLen =
endian::readNext<offset_type, llvm::endianness::little>(D);
// We do not explicitly read the key length because it is a constant.
offset_type KeyLen = sizeof(external_key_type);
offset_type DataLen =
endian::readNext<offset_type, llvm::endianness::little>(D);
return std::make_pair(KeyLen, DataLen);
Expand Down

0 comments on commit de1d4eb

Please sign in to comment.