Skip to content

Commit de1d4eb

Browse files
[memprof] Omit the key length for the call stack table (#89510)
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.
1 parent 37fe3c6 commit de1d4eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ class CallStackWriterTrait {
652652
EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {
653653
using namespace support;
654654
endian::Writer LE(Out, llvm::endianness::little);
655+
// We do not explicitly emit the key length because it is a constant.
655656
offset_type N = sizeof(K);
656-
LE.write<offset_type>(N);
657657
offset_type M = sizeof(FrameId) * V.size();
658658
LE.write<offset_type>(M);
659659
return std::make_pair(N, M);
@@ -697,8 +697,8 @@ class CallStackLookupTrait {
697697
ReadKeyDataLength(const unsigned char *&D) {
698698
using namespace support;
699699

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

0 commit comments

Comments
 (0)