summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_compiler_stats.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2017-02-23 18:56:13 +0000
committerVladimir Marko <vmarko@google.com>2017-02-23 19:06:46 +0000
commit438709f4f2454854f09a3b5c058834bbf772aaa8 (patch)
tree1663b23c67e3eb10e4d91b5d8a63be9239faa20f /compiler/optimizing/optimizing_compiler_stats.h
parentf773e851c620d253d02e81a3e2ae115c5862d73c (diff)
Fix compilation statistics collection in inliner.
Stats from callee graph builder were not merged into main stats and stats for callee graph optimizations were counted even when the callee graph was eventually rejected. Allocate the callee graph statistics on the arena. Measured compilation of a big app using heaptrack: bytes allocated in total (ignoring deallocations): 3.77GB -> 3.37GB calls to allocation functions: 10650510 -> 8203129 Test: testrunner.py --host Test: Stats change in the expected direction for an app. Bug: 34053922 Change-Id: I605280d262b86af14b847acf3bb6dc077b749cc0
Diffstat (limited to 'compiler/optimizing/optimizing_compiler_stats.h')
-rw-r--r--compiler/optimizing/optimizing_compiler_stats.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/compiler/optimizing/optimizing_compiler_stats.h b/compiler/optimizing/optimizing_compiler_stats.h
index 203b1ec7ec..f7f6a14e9d 100644
--- a/compiler/optimizing/optimizing_compiler_stats.h
+++ b/compiler/optimizing/optimizing_compiler_stats.h
@@ -17,6 +17,7 @@
#ifndef ART_COMPILER_OPTIMIZING_OPTIMIZING_COMPILER_STATS_H_
#define ART_COMPILER_OPTIMIZING_OPTIMIZING_COMPILER_STATS_H_
+#include <atomic>
#include <iomanip>
#include <string>
#include <type_traits>
@@ -74,7 +75,7 @@ class OptimizingCompilerStats {
public:
OptimizingCompilerStats() {}
- void RecordStat(MethodCompilationStat stat, size_t count = 1) {
+ void RecordStat(MethodCompilationStat stat, uint32_t count = 1) {
compile_stats_[stat] += count;
}
@@ -93,7 +94,7 @@ class OptimizingCompilerStats {
<< " methods: " << std::fixed << std::setprecision(2)
<< compiled_percent << "% (" << compile_stats_[kCompiled] << ") compiled.";
- for (int i = 0; i < kLastStat; i++) {
+ for (size_t i = 0; i < kLastStat; i++) {
if (compile_stats_[i] != 0) {
LOG(INFO) << PrintMethodCompilationStat(static_cast<MethodCompilationStat>(i)) << ": "
<< compile_stats_[i];
@@ -102,6 +103,21 @@ class OptimizingCompilerStats {
}
}
+ void AddTo(OptimizingCompilerStats* other_stats) {
+ for (size_t i = 0; i != kLastStat; ++i) {
+ uint32_t count = compile_stats_[i];
+ if (count != 0) {
+ other_stats->RecordStat(static_cast<MethodCompilationStat>(i), count);
+ }
+ }
+ }
+
+ void Reset() {
+ for (size_t i = 0; i != kLastStat; ++i) {
+ compile_stats_[i] = 0u;
+ }
+ }
+
private:
std::string PrintMethodCompilationStat(MethodCompilationStat stat) const {
std::string name;
@@ -156,7 +172,7 @@ class OptimizingCompilerStats {
return "OptStat#" + name;
}
- AtomicInteger compile_stats_[kLastStat];
+ std::atomic<uint32_t> compile_stats_[kLastStat];
DISALLOW_COPY_AND_ASSIGN(OptimizingCompilerStats);
};