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

Side by Side Diff: src/heap.cc

Issue 17005005: Reland "Make more GCs in idle notification handler." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 last_gc_end_timestamp_(0.0), 145 last_gc_end_timestamp_(0.0),
146 marking_time_(0.0), 146 marking_time_(0.0),
147 sweeping_time_(0.0), 147 sweeping_time_(0.0),
148 store_buffer_(this), 148 store_buffer_(this),
149 marking_(this), 149 marking_(this),
150 incremental_marking_(this), 150 incremental_marking_(this),
151 number_idle_notifications_(0), 151 number_idle_notifications_(0),
152 last_idle_notification_gc_count_(0), 152 last_idle_notification_gc_count_(0),
153 last_idle_notification_gc_count_init_(false), 153 last_idle_notification_gc_count_init_(false),
154 mark_sweeps_since_idle_round_started_(0), 154 mark_sweeps_since_idle_round_started_(0),
155 ms_count_at_last_idle_notification_(0),
156 gc_count_at_last_idle_gc_(0), 155 gc_count_at_last_idle_gc_(0),
157 scavenges_since_last_idle_round_(kIdleScavengeThreshold), 156 scavenges_since_last_idle_round_(kIdleScavengeThreshold),
158 gcs_since_last_deopt_(0), 157 gcs_since_last_deopt_(0),
159 #ifdef VERIFY_HEAP 158 #ifdef VERIFY_HEAP
160 no_weak_embedded_maps_verification_scope_depth_(0), 159 no_weak_embedded_maps_verification_scope_depth_(0),
161 #endif 160 #endif
162 promotion_queue_(this), 161 promotion_queue_(this),
163 configured_(false), 162 configured_(false),
164 chunks_queued_for_free_(NULL), 163 chunks_queued_for_free_(NULL),
165 relocation_mutex_(NULL) { 164 relocation_mutex_(NULL) {
(...skipping 5686 matching lines...) Expand 10 before | Expand all | Expand 10 after
5852 IncrementalMarking::NO_GC_VIA_STACK_GUARD); 5851 IncrementalMarking::NO_GC_VIA_STACK_GUARD);
5853 5852
5854 if (incremental_marking()->IsComplete()) { 5853 if (incremental_marking()->IsComplete()) {
5855 bool uncommit = false; 5854 bool uncommit = false;
5856 if (gc_count_at_last_idle_gc_ == gc_count_) { 5855 if (gc_count_at_last_idle_gc_ == gc_count_) {
5857 // No GC since the last full GC, the mutator is probably not active. 5856 // No GC since the last full GC, the mutator is probably not active.
5858 isolate_->compilation_cache()->Clear(); 5857 isolate_->compilation_cache()->Clear();
5859 uncommit = true; 5858 uncommit = true;
5860 } 5859 }
5861 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); 5860 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental");
5861 mark_sweeps_since_idle_round_started_++;
5862 gc_count_at_last_idle_gc_ = gc_count_; 5862 gc_count_at_last_idle_gc_ = gc_count_;
5863 if (uncommit) { 5863 if (uncommit) {
5864 new_space_.Shrink(); 5864 new_space_.Shrink();
5865 UncommitFromSpace(); 5865 UncommitFromSpace();
5866 } 5866 }
5867 } 5867 }
5868 } 5868 }
5869 5869
5870 5870
5871 bool Heap::IdleNotification(int hint) { 5871 bool Heap::IdleNotification(int hint) {
5872 // Hints greater than this value indicate that 5872 // Hints greater than this value indicate that
5873 // the embedder is requesting a lot of GC work. 5873 // the embedder is requesting a lot of GC work.
5874 const int kMaxHint = 1000; 5874 const int kMaxHint = 1000;
5875 const int kMinHint = 10;
Hannes Payer (out of office) 2013/06/14 11:48:58 Can we call that kMinHintForIncrementalMarking? Th
ulan 2013/06/14 14:24:20 Done.
5875 // Minimal hint that allows to do full GC. 5876 // Minimal hint that allows to do full GC.
5876 const int kMinHintForFullGC = 100; 5877 const int kMinHintForFullGC = 100;
5877 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; 5878 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4;
5878 // The size factor is in range [5..250]. The numbers here are chosen from 5879 // The size factor is in range [5..250]. The numbers here are chosen from
5879 // experiments. If you changes them, make sure to test with 5880 // experiments. If you changes them, make sure to test with
5880 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* 5881 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.*
5881 intptr_t step_size = 5882 intptr_t step_size =
5882 size_factor * IncrementalMarking::kAllocatedThreshold; 5883 size_factor * IncrementalMarking::kAllocatedThreshold;
5883 5884
5884 if (contexts_disposed_ > 0) { 5885 if (contexts_disposed_ > 0) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5927 } 5928 }
5928 5929
5929 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { 5930 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) {
5930 if (EnoughGarbageSinceLastIdleRound()) { 5931 if (EnoughGarbageSinceLastIdleRound()) {
5931 StartIdleRound(); 5932 StartIdleRound();
5932 } else { 5933 } else {
5933 return true; 5934 return true;
5934 } 5935 }
5935 } 5936 }
5936 5937
5937 int new_mark_sweeps = ms_count_ - ms_count_at_last_idle_notification_;
5938 mark_sweeps_since_idle_round_started_ += new_mark_sweeps;
5939 ms_count_at_last_idle_notification_ = ms_count_;
5940
5941 int remaining_mark_sweeps = kMaxMarkSweepsInIdleRound - 5938 int remaining_mark_sweeps = kMaxMarkSweepsInIdleRound -
5942 mark_sweeps_since_idle_round_started_; 5939 mark_sweeps_since_idle_round_started_;
5943 5940
5944 if (remaining_mark_sweeps <= 0) {
5945 FinishIdleRound();
5946 return true;
5947 }
5948
5949 if (incremental_marking()->IsStopped()) { 5941 if (incremental_marking()->IsStopped()) {
5950 // If there are no more than two GCs left in this idle round and we are 5942 // If there are no more than two GCs left in this idle round and we are
5951 // allowed to do a full GC, then make those GCs full in order to compact 5943 // allowed to do a full GC, then make those GCs full in order to compact
5952 // the code space. 5944 // the code space.
5953 // TODO(ulan): Once we enable code compaction for incremental marking, 5945 // TODO(ulan): Once we enable code compaction for incremental marking,
5954 // we can get rid of this special case and always start incremental marking. 5946 // we can get rid of this special case and always start incremental marking.
5955 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) { 5947 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) {
5956 CollectAllGarbage(kReduceMemoryFootprintMask, 5948 CollectAllGarbage(kReduceMemoryFootprintMask,
5957 "idle notification: finalize idle round"); 5949 "idle notification: finalize idle round");
5958 } else { 5950 mark_sweeps_since_idle_round_started_++;
5951 } else if (hint > kMinHint) {
5959 incremental_marking()->Start(); 5952 incremental_marking()->Start();
5960 } 5953 }
5961 } 5954 }
5962 if (!incremental_marking()->IsStopped()) { 5955 if (!incremental_marking()->IsStopped() && hint > kMinHint) {
5963 AdvanceIdleIncrementalMarking(step_size); 5956 AdvanceIdleIncrementalMarking(step_size);
5964 } 5957 }
5958
5959 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) {
5960 FinishIdleRound();
5961 return true;
5962 }
5963
5965 return false; 5964 return false;
5966 } 5965 }
5967 5966
5968 5967
5969 bool Heap::IdleGlobalGC() { 5968 bool Heap::IdleGlobalGC() {
5970 static const int kIdlesBeforeScavenge = 4; 5969 static const int kIdlesBeforeScavenge = 4;
5971 static const int kIdlesBeforeMarkSweep = 7; 5970 static const int kIdlesBeforeMarkSweep = 7;
5972 static const int kIdlesBeforeMarkCompact = 8; 5971 static const int kIdlesBeforeMarkCompact = 8;
5973 static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1; 5972 static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1;
5974 static const unsigned int kGCsBetweenCleanup = 4; 5973 static const unsigned int kGCsBetweenCleanup = 4;
(...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after
8070 if (FLAG_parallel_recompilation) { 8069 if (FLAG_parallel_recompilation) {
8071 heap_->relocation_mutex_->Lock(); 8070 heap_->relocation_mutex_->Lock();
8072 #ifdef DEBUG 8071 #ifdef DEBUG
8073 heap_->relocation_mutex_locked_by_optimizer_thread_ = 8072 heap_->relocation_mutex_locked_by_optimizer_thread_ =
8074 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 8073 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
8075 #endif // DEBUG 8074 #endif // DEBUG
8076 } 8075 }
8077 } 8076 }
8078 8077
8079 } } // namespace v8::internal 8078 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698