diff options
| -rw-r--r-- | runtime/gc/heap.cc | 4 | ||||
| -rw-r--r-- | runtime/gc/heap.h | 4 | ||||
| -rw-r--r-- | runtime/runtime.cc | 3 |
3 files changed, 5 insertions, 6 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 2f36d02eef..117f747cee 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -214,7 +214,7 @@ Heap::Heap(size_t initial_size, long_gc_log_threshold_(long_gc_log_threshold), process_cpu_start_time_ns_(ProcessCpuNanoTime()), last_process_cpu_time_ns_(process_cpu_start_time_ns_), - weighted_allocated_bytes_(0u), + weighted_allocated_bytes_(0.0), ignore_max_footprint_(ignore_max_footprint), zygote_creation_lock_("zygote creation lock", kZygoteCreationLock), zygote_space_(nullptr), @@ -1072,7 +1072,7 @@ void Heap::RemoveSpace(space::Space* space) { void Heap::CalculateWeightedAllocatedBytes() { uint64_t current_process_cpu_time = ProcessCpuNanoTime(); uint64_t bytes_allocated = GetBytesAllocated(); - uint64_t weight = current_process_cpu_time - last_process_cpu_time_ns_; + double weight = current_process_cpu_time - last_process_cpu_time_ns_; weighted_allocated_bytes_ += weight * bytes_allocated; last_process_cpu_time_ns_ = current_process_cpu_time; } diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index 8d81c11a43..57c7376be6 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -397,7 +397,7 @@ class Heap { REQUIRES(!Locks::heap_bitmap_lock_) REQUIRES(Locks::mutator_lock_); - uint64_t GetWeightedAllocatedBytes() const { + double GetWeightedAllocatedBytes() const { return weighted_allocated_bytes_; } @@ -1179,7 +1179,7 @@ class Heap { uint64_t last_process_cpu_time_ns_; // allocated_bytes * (current_process_cpu_time - last_process_cpu_time) - uint64_t weighted_allocated_bytes_; + double weighted_allocated_bytes_; // If we ignore the max footprint it lets the heap grow until it hits the heap capacity, this is // useful for benchmarking since it reduces time spent in GC to a low %. diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 11e0bf45f9..36f8e89648 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -336,8 +336,7 @@ Runtime::~Runtime() { << " out of process CPU time " << PrettyDuration(process_cpu_time) << " (" << ratio << ")" << "\n"; - float weighted_allocated_bytes = - static_cast<float>(heap_->GetWeightedAllocatedBytes()) / process_cpu_time; + double weighted_allocated_bytes = heap_->GetWeightedAllocatedBytes() / process_cpu_time; LOG_STREAM(INFO) << "Weighted bytes allocated over CPU time: " << " (" << PrettySize(weighted_allocated_bytes) << ")" << "\n"; |