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

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

Issue 449813002: Perform full gcs when context disposals happen too frequent. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/once.h" 9 #include "src/base/once.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), 61 max_old_generation_size_(700ul * (kPointerSize / 4) * MB),
62 max_executable_size_(256ul * (kPointerSize / 4) * MB), 62 max_executable_size_(256ul * (kPointerSize / 4) * MB),
63 // Variables set based on semispace_size_ and old_generation_size_ in 63 // Variables set based on semispace_size_ and old_generation_size_ in
64 // ConfigureHeap. 64 // ConfigureHeap.
65 // Will be 4 * reserved_semispace_size_ to ensure that young 65 // Will be 4 * reserved_semispace_size_ to ensure that young
66 // generation can be aligned to its size. 66 // generation can be aligned to its size.
67 maximum_committed_(0), 67 maximum_committed_(0),
68 survived_since_last_expansion_(0), 68 survived_since_last_expansion_(0),
69 sweep_generation_(0), 69 sweep_generation_(0),
70 always_allocate_scope_depth_(0), 70 always_allocate_scope_depth_(0),
71 contexts_disposed_(0),
72 global_ic_age_(0), 71 global_ic_age_(0),
73 flush_monomorphic_ics_(false), 72 flush_monomorphic_ics_(false),
73 last_notify_context_disposed_(0.0),
74 scan_on_scavenge_pages_(0), 74 scan_on_scavenge_pages_(0),
75 new_space_(this), 75 new_space_(this),
76 old_pointer_space_(NULL), 76 old_pointer_space_(NULL),
77 old_data_space_(NULL), 77 old_data_space_(NULL),
78 code_space_(NULL), 78 code_space_(NULL),
79 map_space_(NULL), 79 map_space_(NULL),
80 cell_space_(NULL), 80 cell_space_(NULL),
81 property_cell_space_(NULL), 81 property_cell_space_(NULL),
82 lo_space_(NULL), 82 lo_space_(NULL),
83 gc_state_(NOT_IN_GC), 83 gc_state_(NOT_IN_GC),
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 if (!mark_compact_collector()->abort_incremental_marking() && 851 if (!mark_compact_collector()->abort_incremental_marking() &&
852 incremental_marking()->IsStopped() && 852 incremental_marking()->IsStopped() &&
853 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull()) { 853 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull()) {
854 incremental_marking()->Start(); 854 incremental_marking()->Start();
855 } 855 }
856 856
857 return next_gc_likely_to_collect_more; 857 return next_gc_likely_to_collect_more;
858 } 858 }
859 859
860 860
861 int Heap::NotifyContextDisposed() { 861 void Heap::NotifyContextDisposed() {
862 double current_notify_context_disposed = base::OS::TimeCurrentMillis();
862 if (isolate()->concurrent_recompilation_enabled()) { 863 if (isolate()->concurrent_recompilation_enabled()) {
863 // Flush the queued recompilation tasks. 864 // Flush the queued recompilation tasks.
864 isolate()->optimizing_compiler_thread()->Flush(); 865 isolate()->optimizing_compiler_thread()->Flush();
865 } 866 }
866 flush_monomorphic_ics_ = true; 867 flush_monomorphic_ics_ = true;
867 AgeInlineCaches(); 868 AgeInlineCaches();
868 return ++contexts_disposed_; 869 if (last_notify_context_disposed_ > 0.0 &&
870 (current_notify_context_disposed - last_notify_context_disposed_ <
871 static_cast<double>(kNotifyContextDisposedFullGCLimitInMS))) {
872 CollectAllGarbage(kReduceMemoryFootprintMask,
873 "notify contexts disposed at high rate");
874 }
875
876 // After context disposal there is likely a lot of garbage remaining, reset
877 // the idle notification counters in order to allow more idle notifcations.
878 StartIdleRound();
879
880 last_notify_context_disposed_ = base::OS::TimeCurrentMillis();
869 } 881 }
870 882
871 883
872 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, 884 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index,
873 int len) { 885 int len) {
874 if (len == 0) return; 886 if (len == 0) return;
875 887
876 DCHECK(array->map() != fixed_cow_array_map()); 888 DCHECK(array->map() != fixed_cow_array_map());
877 Object** dst_objects = array->data_start() + dst_index; 889 Object** dst_objects = array->data_start() + dst_index;
878 MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize); 890 MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize);
(...skipping 3416 matching lines...) Expand 10 before | Expand all | Expand 10 after
4295 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; 4307 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4;
4296 // The size factor is in range [5..250]. The numbers here are chosen from 4308 // The size factor is in range [5..250]. The numbers here are chosen from
4297 // experiments. If you changes them, make sure to test with 4309 // experiments. If you changes them, make sure to test with
4298 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* 4310 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.*
4299 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; 4311 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold;
4300 4312
4301 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample(hint); 4313 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample(hint);
4302 HistogramTimerScope idle_notification_scope( 4314 HistogramTimerScope idle_notification_scope(
4303 isolate_->counters()->gc_idle_notification()); 4315 isolate_->counters()->gc_idle_notification());
4304 4316
4305 if (contexts_disposed_ > 0) {
4306 contexts_disposed_ = 0;
4307 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000);
4308 if (hint >= mark_sweep_time && !FLAG_expose_gc &&
4309 incremental_marking()->IsStopped()) {
4310 HistogramTimerScope scope(isolate_->counters()->gc_context());
4311 CollectAllGarbage(kReduceMemoryFootprintMask,
4312 "idle notification: contexts disposed");
4313 } else {
4314 AdvanceIdleIncrementalMarking(step_size);
4315 }
4316
4317 // After context disposal there is likely a lot of garbage remaining, reset
4318 // the idle notification counters in order to trigger more incremental GCs
4319 // on subsequent idle notifications.
4320 StartIdleRound();
4321 return false;
4322 }
4323
4324 // By doing small chunks of GC work in each IdleNotification,
4325 // perform a round of incremental GCs and after that wait until
4326 // the mutator creates enough garbage to justify a new round.
4327 // An incremental GC progresses as follows:
4328 // 1. many incremental marking steps,
4329 // 2. one old space mark-sweep-compact,
4330 // Use mark-sweep-compact events to count incremental GCs in a round.
4331
4332 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { 4317 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) {
4333 if (EnoughGarbageSinceLastIdleRound()) { 4318 if (EnoughGarbageSinceLastIdleRound()) {
4334 StartIdleRound(); 4319 StartIdleRound();
4335 } else { 4320 } else {
4336 return true; 4321 return true;
4337 } 4322 }
4338 } 4323 }
4339 4324
4340 int remaining_mark_sweeps = 4325 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000);
4341 kMaxMarkSweepsInIdleRound - mark_sweeps_since_idle_round_started_; 4326 // Perform a full gc if there is enough idle time.
4342 4327 if (hint >= mark_sweep_time) {
4343 if (incremental_marking()->IsStopped()) { 4328 CollectAllGarbage(kReduceMemoryFootprintMask,
jochen (gone - plz use gerrit) 2014/08/07 09:14:51 this is a somewhat new behavior, because previousl
Hannes Payer (out of office) 2014/08/07 10:53:30 Yes, this is different. Note that before we were j
4329 "idle notification: finalize idle round");
4330 mark_sweeps_since_idle_round_started_++;
4331 } else if (incremental_marking()->IsStopped()) {
4332 int remaining_mark_sweeps =
4333 kMaxMarkSweepsInIdleRound - mark_sweeps_since_idle_round_started_;
4344 // If there are no more than two GCs left in this idle round and we are 4334 // If there are no more than two GCs left in this idle round and we are
4345 // allowed to do a full GC, then make those GCs full in order to compact 4335 // allowed to do a full GC, then make those GCs full in order to compact
4346 // the code space. 4336 // the code space.
4347 // TODO(ulan): Once we enable code compaction for incremental marking, 4337 // TODO(ulan): Once we enable code compaction for incremental marking,
4348 // we can get rid of this special case and always start incremental marking. 4338 // we can get rid of this special case and always start incremental marking.
4349 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) { 4339 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) {
4350 CollectAllGarbage(kReduceMemoryFootprintMask, 4340 CollectAllGarbage(kReduceMemoryFootprintMask,
4351 "idle notification: finalize idle round"); 4341 "idle notification: finalize idle round");
4352 mark_sweeps_since_idle_round_started_++; 4342 mark_sweeps_since_idle_round_started_++;
4353 } else if (hint > kMinHintForIncrementalMarking) { 4343 } else if (hint > kMinHintForIncrementalMarking) {
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
6143 static_cast<int>(object_sizes_last_time_[index])); 6133 static_cast<int>(object_sizes_last_time_[index]));
6144 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6134 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6145 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6135 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6146 6136
6147 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6137 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6148 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6138 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6149 ClearObjectStats(); 6139 ClearObjectStats();
6150 } 6140 }
6151 } 6141 }
6152 } // namespace v8::internal 6142 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698