diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-11-19 13:28:14 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-11-19 13:28:14 +0000 |
commit | f8b28e9bf4720fc737d4db0985f0d173e3b4f2fa (patch) | |
tree | 80dc0ae8c6bcab9be841aeacd5ddc373baf5fc7f | |
parent | 0b4b512826c7331542348706d7374632c6ea45a0 (diff) | |
download | llvm-f8b28e9bf4720fc737d4db0985f0d173e3b4f2fa.zip llvm-f8b28e9bf4720fc737d4db0985f0d173e3b4f2fa.tar.gz llvm-f8b28e9bf4720fc737d4db0985f0d173e3b4f2fa.tar.bz2 |
[llvm-exegesis] Analysis::writeSnippet(): be smarter about memory allocations.
Summary:
Test data: 500kLOC of benchmark.yaml, 23Mb. (that is a subset of the actual uops benchmark i was trying to analyze!)
Old time: (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*)
Reviewers: courbet, MaskRay, RKSimon, gchatelet, john.brawn
Reviewed By: courbet, MaskRay
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D54382
llvm-svn: 347198
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/Analysis.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index 0dd6bcb..3d7bffd 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp @@ -114,13 +114,11 @@ void Analysis::writeSnippet(llvm::raw_ostream &OS, 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)); } |