From 30b93db5476e3ae2efdaba25fb53fcc3c081da77 Mon Sep 17 00:00:00 2001 From: Matthew Weingarten Date: Wed, 26 Jun 2024 08:37:22 -0700 Subject: [Memprof] Adds the option to collect AccessCountHistograms for memprof. (#94264) Adds compile time flag -mllvm -memprof-histogram and runtime flag histogram=true|false to turn Histogram collection on and off. The -memprof-histogram flag relies on -memprof-use-callbacks=true to work. Updates shadow mapping logic in histogram mode from having one 8 byte counter for 64 bytes, to 1 byte for 8 bytes, capped at 255. Only supports this granularity as of now. Updates the RawMemprofReader and serializing MemoryInfoBlocks to binary format, including changing to a new version of the raw binary format from version 3 to version 4. Updates creating MemoryInfoBlocks with and without Histograms. When two MemoryInfoBlocks are merged, AccessCounts are summed up and the shorter Histogram is removed. Adds a memprof_histogram test case. Initial commit for adding AccessCountHistograms up until RawProfile for memprof --- llvm/unittests/ProfileData/MemProfTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp') diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp index 15eb59e..14623e18 100644 --- a/llvm/unittests/ProfileData/MemProfTest.cpp +++ b/llvm/unittests/ProfileData/MemProfTest.cpp @@ -247,7 +247,7 @@ TEST(MemProf, FillsValue) { TEST(MemProf, PortableWrapper) { MemInfoBlock Info(/*size=*/16, /*access_count=*/7, /*alloc_timestamp=*/1000, /*dealloc_timestamp=*/2000, /*alloc_cpu=*/3, - /*dealloc_cpu=*/4); + /*dealloc_cpu=*/4, /*Histogram=*/0, /*HistogramSize=*/0); const auto Schema = llvm::memprof::getFullSchema(); PortableMemInfoBlock WriteBlock(Info, Schema); @@ -276,7 +276,7 @@ TEST(MemProf, RecordSerializationRoundTripVersion0And1) { MemInfoBlock Info(/*size=*/16, /*access_count=*/7, /*alloc_timestamp=*/1000, /*dealloc_timestamp=*/2000, /*alloc_cpu=*/3, - /*dealloc_cpu=*/4); + /*dealloc_cpu=*/4, /*Histogram=*/0, /*HistogramSize=*/0); llvm::SmallVector> AllocCallStacks = { {0x123, 0x345}, {0x123, 0x567}}; @@ -310,7 +310,7 @@ TEST(MemProf, RecordSerializationRoundTripVerion2) { MemInfoBlock Info(/*size=*/16, /*access_count=*/7, /*alloc_timestamp=*/1000, /*dealloc_timestamp=*/2000, /*alloc_cpu=*/3, - /*dealloc_cpu=*/4); + /*dealloc_cpu=*/4, /*Histogram=*/0, /*HistogramSize=*/0); llvm::SmallVector CallStackIds = {0x123, 0x456}; -- cgit v1.1