Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: src/heap/heap.cc

Issue 1125683004: Add aggregated memory histograms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 4559 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 static_cast<size_t>(idle_time_in_ms), size_of_objects, 4570 static_cast<size_t>(idle_time_in_ms), size_of_objects,
4571 final_incremental_mark_compact_speed_in_bytes_per_ms))) { 4571 final_incremental_mark_compact_speed_in_bytes_per_ms))) {
4572 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); 4572 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental");
4573 ReduceNewSpaceSize(is_long_idle_notification); 4573 ReduceNewSpaceSize(is_long_idle_notification);
4574 return true; 4574 return true;
4575 } 4575 }
4576 return false; 4576 return false;
4577 } 4577 }
4578 4578
4579 4579
4580 static double MonotonicallyIncreasingTimeInMs() { 4580 double Heap::MonotonicallyIncreasingTimeInMs() {
4581 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * 4581 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() *
4582 static_cast<double>(base::Time::kMillisecondsPerSecond); 4582 static_cast<double>(base::Time::kMillisecondsPerSecond);
4583 } 4583 }
4584 4584
4585 4585
4586 bool Heap::IdleNotification(int idle_time_in_ms) { 4586 bool Heap::IdleNotification(int idle_time_in_ms) {
4587 return IdleNotification( 4587 return IdleNotification(
4588 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + 4588 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() +
4589 (static_cast<double>(idle_time_in_ms) / 4589 (static_cast<double>(idle_time_in_ms) /
4590 static_cast<double>(base::Time::kMillisecondsPerSecond))); 4590 static_cast<double>(base::Time::kMillisecondsPerSecond)));
4591 } 4591 }
4592 4592
4593 4593
4594 bool Heap::IdleNotification(double deadline_in_seconds) { 4594 bool Heap::IdleNotification(double deadline_in_seconds) {
4595 CHECK(HasBeenSetUp()); // http://crbug.com/425035 4595 CHECK(HasBeenSetUp()); // http://crbug.com/425035
4596 double deadline_in_ms = 4596 double deadline_in_ms =
4597 deadline_in_seconds * 4597 deadline_in_seconds *
4598 static_cast<double>(base::Time::kMillisecondsPerSecond); 4598 static_cast<double>(base::Time::kMillisecondsPerSecond);
4599 HistogramTimerScope idle_notification_scope( 4599 HistogramTimerScope idle_notification_scope(
4600 isolate_->counters()->gc_idle_notification()); 4600 isolate_->counters()->gc_idle_notification());
4601 double idle_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); 4601 double start_ms = MonotonicallyIncreasingTimeInMs();
4602 double idle_time_in_ms = deadline_in_ms - start_ms;
4602 bool is_long_idle_notification = 4603 bool is_long_idle_notification =
4603 static_cast<size_t>(idle_time_in_ms) > 4604 static_cast<size_t>(idle_time_in_ms) >
4604 GCIdleTimeHandler::kMaxFrameRenderingIdleTime; 4605 GCIdleTimeHandler::kMaxFrameRenderingIdleTime;
4605 4606
4606 GCIdleTimeHandler::HeapState heap_state; 4607 GCIdleTimeHandler::HeapState heap_state;
4607 heap_state.contexts_disposed = contexts_disposed_; 4608 heap_state.contexts_disposed = contexts_disposed_;
4608 heap_state.contexts_disposal_rate = 4609 heap_state.contexts_disposal_rate =
4609 tracer()->ContextDisposalRateInMilliseconds(); 4610 tracer()->ContextDisposalRateInMilliseconds();
4610 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); 4611 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects());
4611 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); 4612 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
(...skipping 23 matching lines...) Expand all
4635 heap_state.used_new_space_size = new_space_.Size(); 4636 heap_state.used_new_space_size = new_space_.Size();
4636 heap_state.new_space_capacity = new_space_.Capacity(); 4637 heap_state.new_space_capacity = new_space_.Capacity();
4637 heap_state.new_space_allocation_throughput_in_bytes_per_ms = 4638 heap_state.new_space_allocation_throughput_in_bytes_per_ms =
4638 static_cast<size_t>( 4639 static_cast<size_t>(
4639 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); 4640 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
4640 4641
4641 GCIdleTimeAction action = 4642 GCIdleTimeAction action =
4642 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); 4643 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state);
4643 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( 4644 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample(
4644 static_cast<int>(idle_time_in_ms)); 4645 static_cast<int>(idle_time_in_ms));
4646 int committed_memory = static_cast<int>(CommittedMemory() / KB);
4647 int used_memory = static_cast<int>(heap_state.size_of_objects / KB);
4648 isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
4649 start_ms, committed_memory);
4650 isolate()->counters()->aggregated_memory_heap_used()->AddSample(start_ms,
4651 used_memory);
4645 4652
4646 bool result = false; 4653 bool result = false;
4647 switch (action.type) { 4654 switch (action.type) {
4648 case DONE: 4655 case DONE:
4649 result = true; 4656 result = true;
4650 break; 4657 break;
4651 case DO_INCREMENTAL_MARKING: { 4658 case DO_INCREMENTAL_MARKING: {
4652 if (incremental_marking()->IsStopped()) { 4659 if (incremental_marking()->IsStopped()) {
4653 incremental_marking()->Start(); 4660 incremental_marking()->Start();
4654 } 4661 }
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
6422 static_cast<int>(object_sizes_last_time_[index])); 6429 static_cast<int>(object_sizes_last_time_[index]));
6423 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6430 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6424 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6431 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6425 6432
6426 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6433 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6427 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6434 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6428 ClearObjectStats(); 6435 ClearObjectStats();
6429 } 6436 }
6430 } 6437 }
6431 } // namespace v8::internal 6438 } // namespace v8::internal
OLDNEW
« src/counters.h ('K') | « src/heap/heap.h ('k') | test/unittests/counters-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698