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

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

Issue 1148633005: Uncommit and shrink semi-spaces only on low allocation rate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 4547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 if (!IsHeapIterable()) { 4558 if (!IsHeapIterable()) {
4559 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); 4559 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable");
4560 } 4560 }
4561 if (mark_compact_collector()->sweeping_in_progress()) { 4561 if (mark_compact_collector()->sweeping_in_progress()) {
4562 mark_compact_collector()->EnsureSweepingCompleted(); 4562 mark_compact_collector()->EnsureSweepingCompleted();
4563 } 4563 }
4564 DCHECK(IsHeapIterable()); 4564 DCHECK(IsHeapIterable());
4565 } 4565 }
4566 4566
4567 4567
4568 void Heap::ReduceNewSpaceSize(GCIdleTimeAction action) { 4568 bool Heap::HasLowAllocationRate(GCIdleTimeHandler::HeapState heap_state) {
4569 if (action.reduce_memory && 4569 static const size_t kLowAllocationRate = 1000;
4570 return heap_state.current_new_space_allocation_throughput_in_bytes_per_ms <
ulan 2015/05/21 15:21:25 check for heap_state.current_new_space_allocation_
Hannes Payer (out of office) 2015/05/21 17:17:03 Good point! Done.
4571 kLowAllocationRate;
4572 }
4573
4574
4575 void Heap::ReduceNewSpaceSize(GCIdleTimeAction action,
4576 GCIdleTimeHandler::HeapState heap_state) {
4577 if (HasLowAllocationRate(heap_state) &&
4570 (action.type == DO_SCAVENGE || action.type == DO_FULL_GC || 4578 (action.type == DO_SCAVENGE || action.type == DO_FULL_GC ||
4571 (action.type == DO_INCREMENTAL_MARKING && 4579 (action.type == DO_INCREMENTAL_MARKING &&
4572 incremental_marking()->IsStopped()))) { 4580 incremental_marking()->IsStopped()))) {
4573 new_space_.Shrink(); 4581 new_space_.Shrink();
4574 UncommitFromSpace(); 4582 UncommitFromSpace();
4575 } 4583 }
4576 } 4584 }
4577 4585
4578 4586
4579 bool Heap::TryFinalizeIdleIncrementalMarking( 4587 bool Heap::TryFinalizeIdleIncrementalMarking(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4628 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); 4636 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
4629 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = 4637 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms =
4630 static_cast<size_t>( 4638 static_cast<size_t>(
4631 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); 4639 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond());
4632 heap_state.scavenge_speed_in_bytes_per_ms = 4640 heap_state.scavenge_speed_in_bytes_per_ms =
4633 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); 4641 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond());
4634 heap_state.used_new_space_size = new_space_.Size(); 4642 heap_state.used_new_space_size = new_space_.Size();
4635 heap_state.new_space_capacity = new_space_.Capacity(); 4643 heap_state.new_space_capacity = new_space_.Capacity();
4636 heap_state.new_space_allocation_throughput_in_bytes_per_ms = 4644 heap_state.new_space_allocation_throughput_in_bytes_per_ms =
4637 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); 4645 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond();
4646 heap_state.current_new_space_allocation_throughput_in_bytes_per_ms =
4647 tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond();
4638 return heap_state; 4648 return heap_state;
4639 } 4649 }
4640 4650
4641 4651
4642 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, 4652 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action,
4643 GCIdleTimeHandler::HeapState heap_state, 4653 GCIdleTimeHandler::HeapState heap_state,
4644 double deadline_in_ms, 4654 double deadline_in_ms,
4645 bool is_long_idle_notification) { 4655 bool is_long_idle_notification) {
4646 bool result = false; 4656 bool result = false;
4647 switch (action.type) { 4657 switch (action.type) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4690 case DO_SCAVENGE: 4700 case DO_SCAVENGE:
4691 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); 4701 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4692 break; 4702 break;
4693 case DO_FINALIZE_SWEEPING: 4703 case DO_FINALIZE_SWEEPING:
4694 mark_compact_collector()->EnsureSweepingCompleted(); 4704 mark_compact_collector()->EnsureSweepingCompleted();
4695 break; 4705 break;
4696 case DO_NOTHING: 4706 case DO_NOTHING:
4697 break; 4707 break;
4698 } 4708 }
4699 4709
4700 ReduceNewSpaceSize(action); 4710 ReduceNewSpaceSize(action, heap_state);
4701 return result; 4711 return result;
4702 } 4712 }
4703 4713
4704 4714
4705 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, 4715 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action,
4706 GCIdleTimeHandler::HeapState heap_state, 4716 GCIdleTimeHandler::HeapState heap_state,
4707 double start_ms, double deadline_in_ms, 4717 double start_ms, double deadline_in_ms,
4708 bool is_long_idle_notification) { 4718 bool is_long_idle_notification) {
4709 double idle_time_in_ms = deadline_in_ms - start_ms; 4719 double idle_time_in_ms = deadline_in_ms - start_ms;
4710 double current_time = MonotonicallyIncreasingTimeInMs(); 4720 double current_time = MonotonicallyIncreasingTimeInMs();
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
6587 *object_type = "CODE_TYPE"; \ 6597 *object_type = "CODE_TYPE"; \
6588 *object_sub_type = "CODE_AGE/" #name; \ 6598 *object_sub_type = "CODE_AGE/" #name; \
6589 return true; 6599 return true;
6590 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6600 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6591 #undef COMPARE_AND_RETURN_NAME 6601 #undef COMPARE_AND_RETURN_NAME
6592 } 6602 }
6593 return false; 6603 return false;
6594 } 6604 }
6595 } 6605 }
6596 } // namespace v8::internal 6606 } // namespace v8::internal
OLDNEW
« src/heap/gc-tracer.cc ('K') | « src/heap/heap.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698