-
Notifications
You must be signed in to change notification settings - Fork 15k
[memprof] Add RecordSerializationRoundTripVersion4HotColdSchema #156783
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
[memprof] Add RecordSerializationRoundTripVersion4HotColdSchema #156783
Conversation
I'm planning to remove the V2 support. Now, HotColdSchema is one feature that's tested in V2 but not in V4. This patch derives: RecordSerializationRoundTripVersion4HotColdSchema from: RecordSerializationRoundTripVersion2HotColdSchema and then adds DummyMap, a V4-speicifc item.
@llvm/pr-subscribers-pgo Author: Kazu Hirata (kazutakahirata) ChangesI'm planning to remove the V2 support. Now, HotColdSchema is one This patch derives: RecordSerializationRoundTripVersion4HotColdSchema from: RecordSerializationRoundTripVersion2HotColdSchema and then adds DummyMap, a V4-speicifc item. Full diff: https://github.com/llvm/llvm-project/pull/156783.diff 1 Files Affected:
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index b57567e29f1c8..abe36bc759658 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -404,6 +404,75 @@ TEST(MemProf, RecordSerializationRoundTripVersion2HotColdSchema) {
EXPECT_EQ(Record, GotRecord);
}
+TEST(MemProf, RecordSerializationRoundTripVersion4HotColdSchema) {
+ const auto Schema = getHotColdSchema();
+
+ MemInfoBlock Info;
+ Info.AllocCount = 11;
+ Info.TotalSize = 22;
+ Info.TotalLifetime = 33;
+ Info.TotalLifetimeAccessDensity = 44;
+
+ llvm::SmallVector<CallStackId> CallStackIds = {0x123, 0x456};
+
+ llvm::SmallVector<CallStackId> CallSiteIds = {0x333, 0x444};
+
+ IndexedMemProfRecord Record;
+ for (const auto &CSId : CallStackIds) {
+ // Use the same info block for both allocation sites.
+ Record.AllocSites.emplace_back(CSId, Info, Schema);
+ }
+ for (auto CSId : CallSiteIds)
+ Record.CallSites.push_back(IndexedCallSiteInfo(CSId));
+
+ std::bitset<llvm::to_underlying(Meta::Size)> SchemaBitSet;
+ for (auto Id : Schema)
+ SchemaBitSet.set(llvm::to_underlying(Id));
+
+ // Verify that SchemaBitSet has the fields we expect and nothing else, which
+ // we check with count().
+ EXPECT_EQ(SchemaBitSet.count(), 4U);
+ EXPECT_TRUE(SchemaBitSet[llvm::to_underlying(Meta::AllocCount)]);
+ EXPECT_TRUE(SchemaBitSet[llvm::to_underlying(Meta::TotalSize)]);
+ EXPECT_TRUE(SchemaBitSet[llvm::to_underlying(Meta::TotalLifetime)]);
+ EXPECT_TRUE(
+ SchemaBitSet[llvm::to_underlying(Meta::TotalLifetimeAccessDensity)]);
+
+ // Verify that Schema has propagated all the way to the Info field in each
+ // IndexedAllocationInfo.
+ ASSERT_THAT(Record.AllocSites, SizeIs(2));
+ EXPECT_EQ(Record.AllocSites[0].Info.getSchema(), SchemaBitSet);
+ EXPECT_EQ(Record.AllocSites[1].Info.getSchema(), SchemaBitSet);
+
+ std::string Buffer;
+ llvm::raw_string_ostream OS(Buffer);
+ // Need a dummy map for V4 serialization
+ llvm::DenseMap<CallStackId, LinearCallStackId> DummyMap = {
+ {0x123, 1}, {0x456, 2}, {0x333, 3}, {0x444, 4}};
+ Record.serialize(Schema, OS, Version4, &DummyMap);
+
+ const IndexedMemProfRecord GotRecord = IndexedMemProfRecord::deserialize(
+ Schema, reinterpret_cast<const unsigned char *>(Buffer.data()), Version4);
+
+ // Verify that Schema comes back correctly after deserialization. Technically,
+ // the comparison between Record and GotRecord below includes the comparison
+ // of their Schemas, but we'll verify the Schemas on our own.
+ ASSERT_THAT(GotRecord.AllocSites, SizeIs(2));
+ EXPECT_EQ(GotRecord.AllocSites[0].Info.getSchema(), SchemaBitSet);
+ EXPECT_EQ(GotRecord.AllocSites[1].Info.getSchema(), SchemaBitSet);
+
+ // Create the expected record using the linear IDs from the dummy map.
+ IndexedMemProfRecord ExpectedRecord;
+ for (const auto &CSId : CallStackIds) {
+ ExpectedRecord.AllocSites.emplace_back(DummyMap[CSId], Info, Schema);
+ }
+ for (const auto &CSId : CallSiteIds) {
+ ExpectedRecord.CallSites.emplace_back(DummyMap[CSId]);
+ }
+
+ EXPECT_EQ(ExpectedRecord, GotRecord);
+}
+
TEST(MemProf, SymbolizationFilter) {
auto Symbolizer = std::make_unique<MockSymbolizer>();
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/22201 Here is the relevant piece of the build log for the reference
|
I'm planning to remove the V2 support. Now, HotColdSchema is one
feature that's tested in V2 but not in V4.
This patch derives:
RecordSerializationRoundTripVersion4HotColdSchema
from:
RecordSerializationRoundTripVersion2HotColdSchema
and then adds DummyMap, a V4-speicifc item.