[PATCH] D41152: Use a custom container to reduce AFDO's memory usage by ~60%

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 20:27:12 PST 2017


davidxl added a comment.

Is it enough to simply replace StringMap with std::map<std::string, ..> for small maps? Do you have memory data with that?



================
Comment at: include/llvm/ProfileData/SampleProf.h:188
 
-using BodySampleMap = std::map<LineLocation, SampleRecord>;
-using FunctionSamplesMap = StringMap<FunctionSamples>;
-using CallsiteSampleMap = std::map<LineLocation, FunctionSamplesMap>;
+using BodySampleMap = TinyAssociativeVector<LineLocation, SampleRecord>;
+using FunctionSamplesMap = TinyAssociativeVector<StringRef, FunctionSamples>;
----------------
I wonder how much is saved by replacing just std::map with TinyAssociativeVector. 


================
Comment at: include/llvm/ProfileData/SampleProf.h:426
 raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
-
-/// Sort a LocationT->SampleT map by LocationT.
----------------
Can you split out this clean up change into a separate patch?


https://reviews.llvm.org/D41152





More information about the llvm-commits mailing list