[PATCH] D54383: [llvm-exegesis] Analysis: writeMeasurementValue(): don't alloc string for double each time.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 10 13:57:57 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/D54382)

  $ 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.601s
  user    0m8.881s
  sys     0m0.720s

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.790s
  user    0m9.086s
  sys     0m0.700s

Within noise, i'm not actually benchmarking, only measuring the ballpark. But this isn't the important part.

Old:

- calls to allocation functions: 2109712
- temporary allocations: 33112
- bytes allocated in total (ignoring deallocations): 4.43 GB

New:

- calls to allocation functions: 2095345 (-0.68%)
- temporary allocations: 18745 (-43.39% !!!)
- bytes allocated in total (ignoring deallocations): 4.31 GB (-2.71%)


Repository:
  rL LLVM

https://reviews.llvm.org/D54383

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
@@ -12,6 +12,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/Support/FormatVariadic.h"
+#include <limits>
 #include <unordered_set>
 #include <vector>
 
@@ -95,7 +96,9 @@
 
 template <EscapeTag Tag>
 static void writeMeasurementValue(llvm::raw_ostream &OS, const double Value) {
-  writeEscaped<Tag>(OS, llvm::formatv("{0:F}", Value).str());
+  writeEscaped<Tag>(
+      OS, llvm::formatv("{0:F}", Value)
+              .sstr<1 + std::numeric_limits<decltype(Value)>::max_digits10>());
 }
 
 template <typename EscapeTag, EscapeTag Tag>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54383.173528.patch
Type: text/x-patch
Size: 769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181110/b2683f28/attachment.bin>


More information about the llvm-commits mailing list