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

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

Issue 1705183003: Activate memory reducer for small heaps in background tabs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: typo Created 4 years, 10 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | 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/heap/heap.h" 5 #include "src/heap/heap.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/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1053
1054 return next_gc_likely_to_collect_more; 1054 return next_gc_likely_to_collect_more;
1055 } 1055 }
1056 1056
1057 1057
1058 int Heap::NotifyContextDisposed(bool dependant_context) { 1058 int Heap::NotifyContextDisposed(bool dependant_context) {
1059 if (!dependant_context) { 1059 if (!dependant_context) {
1060 tracer()->ResetSurvivalEvents(); 1060 tracer()->ResetSurvivalEvents();
1061 old_generation_size_configured_ = false; 1061 old_generation_size_configured_ = false;
1062 MemoryReducer::Event event; 1062 MemoryReducer::Event event;
1063 event.type = MemoryReducer::kContextDisposed; 1063 event.type = MemoryReducer::kPossibleGarbage;
1064 event.time_ms = MonotonicallyIncreasingTimeInMs(); 1064 event.time_ms = MonotonicallyIncreasingTimeInMs();
1065 memory_reducer_->NotifyContextDisposed(event); 1065 memory_reducer_->NotifyPossibleGarbage(event);
1066 } 1066 }
1067 if (isolate()->concurrent_recompilation_enabled()) { 1067 if (isolate()->concurrent_recompilation_enabled()) {
1068 // Flush the queued recompilation tasks. 1068 // Flush the queued recompilation tasks.
1069 isolate()->optimizing_compile_dispatcher()->Flush(); 1069 isolate()->optimizing_compile_dispatcher()->Flush();
1070 } 1070 }
1071 AgeInlineCaches(); 1071 AgeInlineCaches();
1072 number_of_disposed_maps_ = retained_maps()->Length(); 1072 number_of_disposed_maps_ = retained_maps()->Length();
1073 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); 1073 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs());
1074 return ++contexts_disposed_; 1074 return ++contexts_disposed_;
1075 } 1075 }
(...skipping 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after
4105 } 4105 }
4106 4106
4107 4107
4108 bool Heap::HasHighFragmentation(intptr_t used, intptr_t committed) { 4108 bool Heap::HasHighFragmentation(intptr_t used, intptr_t committed) {
4109 const intptr_t kSlack = 16 * MB; 4109 const intptr_t kSlack = 16 * MB;
4110 // Fragmentation is high if committed > 2 * used + kSlack. 4110 // Fragmentation is high if committed > 2 * used + kSlack.
4111 // Rewrite the exression to avoid overflow. 4111 // Rewrite the exression to avoid overflow.
4112 return committed - used > used + kSlack; 4112 return committed - used > used + kSlack;
4113 } 4113 }
4114 4114
4115 void Heap::SetOptimizeForMemoryUsage() {
4116 // Activate memory reducer when switching to background if
4117 // - there was no mark compact since the start.
4118 // - the committed memory can be potentially reduced.
4119 // 2 pages for the old, code, and map space + 1 page for new space.
4120 const int kMinCommittedMemory = 7 * Page::kPageSize;
4121 if (ms_count_ == 0 && CommittedMemory() > kMinCommittedMemory) {
4122 MemoryReducer::Event event;
4123 event.type = MemoryReducer::kPossibleGarbage;
4124 event.time_ms = MonotonicallyIncreasingTimeInMs();
4125 memory_reducer_->NotifyPossibleGarbage(event);
4126 }
4127 optimize_for_memory_usage_ = true;
4128 }
4115 4129
4116 void Heap::ReduceNewSpaceSize() { 4130 void Heap::ReduceNewSpaceSize() {
4117 // TODO(ulan): Unify this constant with the similar constant in 4131 // TODO(ulan): Unify this constant with the similar constant in
4118 // GCIdleTimeHandler once the change is merged to 4.5. 4132 // GCIdleTimeHandler once the change is merged to 4.5.
4119 static const size_t kLowAllocationThroughput = 1000; 4133 static const size_t kLowAllocationThroughput = 1000;
4120 const size_t allocation_throughput = 4134 const size_t allocation_throughput =
4121 tracer()->CurrentAllocationThroughputInBytesPerMillisecond(); 4135 tracer()->CurrentAllocationThroughputInBytesPerMillisecond();
4122 4136
4123 if (FLAG_predictable) return; 4137 if (FLAG_predictable) return;
4124 4138
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 } 6299 }
6286 6300
6287 6301
6288 // static 6302 // static
6289 int Heap::GetStaticVisitorIdForMap(Map* map) { 6303 int Heap::GetStaticVisitorIdForMap(Map* map) {
6290 return StaticVisitorBase::GetVisitorId(map); 6304 return StaticVisitorBase::GetVisitorId(map);
6291 } 6305 }
6292 6306
6293 } // namespace internal 6307 } // namespace internal
6294 } // namespace v8 6308 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698