diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-11-19 13:28:17 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-11-19 13:28:17 +0000 |
commit | b311c1d6b866f70e107c2054ebc0763d84cbb98f (patch) | |
tree | 986db12b655c5af2f81fba4f2a5c1db3bff3e16b /llvm/tools/llvm-exegesis/lib/Analysis.cpp | |
parent | f8b28e9bf4720fc737d4db0985f0d173e3b4f2fa (diff) | |
download | llvm-b311c1d6b866f70e107c2054ebc0763d84cbb98f.zip llvm-b311c1d6b866f70e107c2054ebc0763d84cbb98f.tar.gz llvm-b311c1d6b866f70e107c2054ebc0763d84cbb98f.tar.bz2 |
[llvm-exegesis] Analysis: writeMeasurementValue(): don't alloc string for double each time.
Summary:
Test data: 500kLOC of benchmark.yaml, 23Mb. (that is a subset of the actual uops benchmark i was trying to analyze!)
Old time: (D54382)
```
Performance counter stats for './bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html' (16 runs):
9024.354355 task-clock (msec) # 1.000 CPUs utilized ( +- 0.18% )
...
9.0262 +- 0.0161 seconds time elapsed ( +- 0.18% )
```
New time:
```
Performance counter stats for './bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html' (16 runs):
8996.541057 task-clock (msec) # 0.999 CPUs utilized ( +- 0.19% )
...
9.0045 +- 0.0172 seconds time elapsed ( +- 0.19% )
```
-~0.3%, not that much. 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%)
Reviewers: courbet, MaskRay, RKSimon, gchatelet, john.brawn
Reviewed By: courbet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D54383
llvm-svn: 347199
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Analysis.cpp')
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/Analysis.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index 3d7bffd..0a91679 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/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,21 @@ writeClusterId(llvm::raw_ostream &OS, template <EscapeTag Tag> static void writeMeasurementValue(llvm::raw_ostream &OS, const double Value) { - writeEscaped<Tag>(OS, llvm::formatv("{0:F}", Value).str()); + // Given Value, if we wanted to serialize it to a string, + // how many base-10 digits will we need to store, max? + static constexpr auto MaxDigitCount = + std::numeric_limits<decltype(Value)>::max_digits10; + // Also, we will need a decimal separator. + static constexpr auto DecimalSeparatorLen = 1; // '.' e.g. + // So how long of a string will the serialization produce, max? + static constexpr auto SerializationLen = MaxDigitCount + DecimalSeparatorLen; + + // WARNING: when changing the format, also adjust the small-size estimate ^. + static constexpr StringLiteral SimpleFloatFormat = StringLiteral("{0:F}"); + + writeEscaped<Tag>( + OS, + llvm::formatv(SimpleFloatFormat.data(), Value).sstr<SerializationLen>()); } template <typename EscapeTag, EscapeTag Tag> |