[PATCH] D54382: [llvm-exegesis] Analysis::writeSnippet(): be smarter about memory allocations.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 10 13:11:44 PST 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: courbet, MaskRay, RKSimon, gchatelet, john.brawn.
Herald added a subscriber: tschuett.

Test data: 500kLOC of benchmark.yaml, 23Mb. (that is a subset of the actual uops benchmark i was trying to analyze!)
Old time: (https://reviews.llvm.org/D54381)

  $ time ./bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html &> /dev/null
  
  real    0m10.487s
  user    0m9.745s
  sys     0m0.740s

New time:

  $ time ./bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html &> /dev/null
  
  real    0m9.599s
  user    0m8.824s
  sys     0m0.772s

Not that much, around -9%. But that is not the good part yet, again.

Old:

- calls to allocation functions: 3347676
- temporary allocations: 277818
- bytes allocated in total (ignoring deallocations): 10.52 GB

New:

- calls to allocation functions: 2109712 (-36%)
- temporary allocations: 33112 (-88%)
- bytes allocated in total (ignoring deallocations): 4.43 GB (-58% *sic*)


Repository:
  rL LLVM

https://reviews.llvm.org/D54382

Files:
  tools/llvm-exegesis/lib/Analysis.cpp


Index: tools/llvm-exegesis/lib/Analysis.cpp
===================================================================
--- tools/llvm-exegesis/lib/Analysis.cpp
+++ tools/llvm-exegesis/lib/Analysis.cpp
@@ -114,13 +114,11 @@
       writeEscaped<Tag>(OS, "[error decoding asm snippet]");
       return;
     }
-    Lines.emplace_back();
-    std::string &Line = Lines.back();
-    llvm::raw_string_ostream OSS(Line);
+    llvm::SmallString<128> InstPrinterStr; // FIXME: magic number.
+    llvm::raw_svector_ostream OSS(InstPrinterStr);
     InstPrinter_->printInst(&MI, OSS, "", *SubtargetInfo_);
     Bytes = Bytes.drop_front(MISize);
-    OSS.flush();
-    Line = llvm::StringRef(Line).trim().str();
+    Lines.emplace_back(llvm::StringRef(InstPrinterStr).trim());
   }
   writeEscaped<Tag>(OS, llvm::join(Lines, Separator));
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54382.173527.patch
Type: text/x-patch
Size: 822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181110/4d727f35/attachment.bin>


More information about the llvm-commits mailing list