diff options
author | 2016-03-08 16:57:48 +0000 | |
---|---|---|
committer | 2016-03-16 11:16:49 +0000 | |
commit | a4f81546373f4cb5fa6dfc135307ee0a1d930872 (patch) | |
tree | bfc592fc0ec418ac8bbc270a31c6e741849c3276 | |
parent | e70cda6147e2e49384a219b167a6c734a8db28f5 (diff) |
Collect memory use for the JIT.
bug:27520994
Change-Id: I67b0c5b822001bfde8738a988c1ade69f1a26e3f
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 3 | ||||
-rw-r--r-- | runtime/base/histogram-inl.h | 8 | ||||
-rw-r--r-- | runtime/base/histogram.h | 1 | ||||
-rw-r--r-- | runtime/jit/jit.cc | 15 | ||||
-rw-r--r-- | runtime/jit/jit.h | 18 |
5 files changed, 38 insertions, 7 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 7a82063bba..53bd38d0ef 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -63,6 +63,7 @@ #include "instruction_simplifier_arm.h" #include "intrinsics.h" #include "jit/debugger_interface.h" +#include "jit/jit.h" #include "jit/jit_code_cache.h" #include "jni/quick/jni_compiler.h" #include "licm.h" @@ -945,6 +946,8 @@ bool OptimizingCompiler::JitCompile(Thread* self, elf_file.size()); } + Runtime::Current()->GetJit()->AddMemoryUsage(method, arena.BytesUsed()); + return true; } diff --git a/runtime/base/histogram-inl.h b/runtime/base/histogram-inl.h index 03980e3273..c7a0ba2dfd 100644 --- a/runtime/base/histogram-inl.h +++ b/runtime/base/histogram-inl.h @@ -26,6 +26,7 @@ #include "base/bit_utils.h" #include "base/time_utils.h" +#include "utils.h" namespace art { @@ -200,6 +201,13 @@ inline void Histogram<Value>::PrintConfidenceIntervals(std::ostream &os, double } template <class Value> +inline void Histogram<Value>::PrintMemoryUse(std::ostream &os) const { + os << Name() + << ": Avg: " << PrettySize(Mean()) << " Max: " + << PrettySize(Max()) << " Min: " << PrettySize(Min()) << "\n"; +} + +template <class Value> inline void Histogram<Value>::CreateHistogram(CumulativeData* out_data) const { DCHECK_GT(sample_size_, 0ull); out_data->freq_.clear(); diff --git a/runtime/base/histogram.h b/runtime/base/histogram.h index ef3a5d78ca..bcb7b3b769 100644 --- a/runtime/base/histogram.h +++ b/runtime/base/histogram.h @@ -59,6 +59,7 @@ template <class Value> class Histogram { double Percentile(double per, const CumulativeData& data) const; void PrintConfidenceIntervals(std::ostream& os, double interval, const CumulativeData& data) const; + void PrintMemoryUse(std::ostream& os) const; void PrintBins(std::ostream& os, const CumulativeData& data) const; void DumpBins(std::ostream& os) const; Value GetRange(size_t bucket_idx) const; diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc index 5bd9a6b76b..7e73e5c7f1 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -83,6 +83,8 @@ JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& opt void Jit::DumpInfo(std::ostream& os) { code_cache_->Dump(os); cumulative_timings_.Dump(os); + MutexLock mu(Thread::Current(), lock_); + memory_use_.PrintMemoryUse(os); } void Jit::AddTimingLogger(const TimingLogger& logger) { @@ -95,6 +97,8 @@ Jit::Jit() : jit_library_handle_(nullptr), jit_compile_method_(nullptr), dump_info_on_shutdown_(false), cumulative_timings_("JIT timings"), + memory_use_("Memory used for compilation", 16), + lock_("JIT memory use lock"), save_profiling_info_(false), generate_debug_info_(false) { } @@ -433,5 +437,16 @@ bool Jit::MaybeDoOnStackReplacement(Thread* thread, return true; } +void Jit::AddMemoryUsage(ArtMethod* method, size_t bytes) { + if (bytes > 4 * MB) { + LOG(INFO) << "Compiler allocated " + << PrettySize(bytes) + << " to compile " + << PrettyMethod(method); + } + MutexLock mu(Thread::Current(), lock_); + memory_use_.AddValue(bytes); +} + } // namespace jit } // namespace art diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h index d5c213416a..37d0bdb129 100644 --- a/runtime/jit/jit.h +++ b/runtime/jit/jit.h @@ -17,14 +17,11 @@ #ifndef ART_RUNTIME_JIT_JIT_H_ #define ART_RUNTIME_JIT_JIT_H_ -#include <unordered_map> - -#include "atomic.h" +#include "base/arena_allocator.h" +#include "base/histogram-inl.h" #include "base/macros.h" #include "base/mutex.h" #include "base/timing_logger.h" -#include "gc_root.h" -#include "jni.h" #include "object_callbacks.h" #include "offline_profiling_info.h" #include "thread_pool.h" @@ -62,9 +59,14 @@ class Jit { void DeleteThreadPool(); // Dump interesting info: #methods compiled, code vs data size, compile / verify cumulative // loggers. - void DumpInfo(std::ostream& os); + void DumpInfo(std::ostream& os) REQUIRES(!lock_); // Add a timing logger to cumulative_timings_. void AddTimingLogger(const TimingLogger& logger); + + void AddMemoryUsage(ArtMethod* method, size_t bytes) + REQUIRES(!lock_) + SHARED_REQUIRES(Locks::mutator_lock_); + JitInstrumentationCache* GetInstrumentationCache() const { return instrumentation_cache_.get(); } @@ -82,7 +84,7 @@ class Jit { const std::string& app_dir); void StopProfileSaver(); - void DumpForSigQuit(std::ostream& os) { + void DumpForSigQuit(std::ostream& os) REQUIRES(!lock_) { DumpInfo(os); } @@ -125,6 +127,8 @@ class Jit { // Performance monitoring. bool dump_info_on_shutdown_; CumulativeLogger cumulative_timings_; + Histogram<uint64_t> memory_use_ GUARDED_BY(lock_); + Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; std::unique_ptr<jit::JitInstrumentationCache> instrumentation_cache_; std::unique_ptr<jit::JitCodeCache> code_cache_; |