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

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

Issue 2057103002: Tune the memory pressure handler to perform a second GC immediately (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: x Created 4 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
« no previous file with comments | « no previous file | test/cctest/heap/test-heap.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 4448 matching lines...) Expand 10 before | Expand all | Expand 10 after
4459 StartIdleIncrementalMarking(); 4459 StartIdleIncrementalMarking();
4460 } 4460 }
4461 } 4461 }
4462 MemoryReducer::Event event; 4462 MemoryReducer::Event event;
4463 event.type = MemoryReducer::kPossibleGarbage; 4463 event.type = MemoryReducer::kPossibleGarbage;
4464 event.time_ms = MonotonicallyIncreasingTimeInMs(); 4464 event.time_ms = MonotonicallyIncreasingTimeInMs();
4465 memory_reducer_->NotifyPossibleGarbage(event); 4465 memory_reducer_->NotifyPossibleGarbage(event);
4466 } 4466 }
4467 4467
4468 void Heap::CollectGarbageOnMemoryPressure(const char* source) { 4468 void Heap::CollectGarbageOnMemoryPressure(const char* source) {
4469 const int kGarbageThresholdInBytes = 8 * MB;
4470 const double kGarbageThresholdAsFractionOfTotalMemory = 0.1;
4471 // This constant is the maximum response time in RAIL performance model.
4472 const double kMaxMemoryPressurePauseMs = 100;
4473
4474 double start = MonotonicallyIncreasingTimeInMs();
4469 CollectAllGarbage(kReduceMemoryFootprintMask | kAbortIncrementalMarkingMask, 4475 CollectAllGarbage(kReduceMemoryFootprintMask | kAbortIncrementalMarkingMask,
4470 source); 4476 source, kGCCallbackFlagCollectAllAvailableGarbage);
4477 double end = MonotonicallyIncreasingTimeInMs();
4478
4479 // Estimate how much memory we can free.
4480 int64_t potential_garbage = (CommittedMemory() - SizeOfObjects()) +
4481 amount_of_external_allocated_memory_;
4482 // If we can potentially free large amount of memory, then start GC right
4483 // away instead of waiting for memory reducer.
4484 if (potential_garbage >= kGarbageThresholdInBytes &&
4485 potential_garbage >=
4486 CommittedMemory() * kGarbageThresholdAsFractionOfTotalMemory) {
4487 // If we spent less than half of the time budget, then perform full GC
4488 // Otherwise, start incremental marking.
4489 if (end - start < kMaxMemoryPressurePauseMs / 2) {
4490 CollectAllGarbage(
4491 kReduceMemoryFootprintMask | kAbortIncrementalMarkingMask, source,
4492 kGCCallbackFlagCollectAllAvailableGarbage);
4493 } else {
4494 if (FLAG_incremental_marking && incremental_marking()->IsStopped()) {
4495 StartIdleIncrementalMarking();
4496 }
4497 }
4498 }
4471 } 4499 }
4472 4500
4473 void Heap::MemoryPressureNotification(MemoryPressureLevel level, 4501 void Heap::MemoryPressureNotification(MemoryPressureLevel level,
4474 bool is_isolate_locked) { 4502 bool is_isolate_locked) {
4475 MemoryPressureLevel previous = memory_pressure_level_.Value(); 4503 MemoryPressureLevel previous = memory_pressure_level_.Value();
4476 memory_pressure_level_.SetValue(level); 4504 memory_pressure_level_.SetValue(level);
4477 if ((previous != MemoryPressureLevel::kCritical && 4505 if ((previous != MemoryPressureLevel::kCritical &&
4478 level == MemoryPressureLevel::kCritical) || 4506 level == MemoryPressureLevel::kCritical) ||
4479 (previous == MemoryPressureLevel::kNone && 4507 (previous == MemoryPressureLevel::kNone &&
4480 level == MemoryPressureLevel::kModerate)) { 4508 level == MemoryPressureLevel::kModerate)) {
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after
6425 } 6453 }
6426 6454
6427 6455
6428 // static 6456 // static
6429 int Heap::GetStaticVisitorIdForMap(Map* map) { 6457 int Heap::GetStaticVisitorIdForMap(Map* map) {
6430 return StaticVisitorBase::GetVisitorId(map); 6458 return StaticVisitorBase::GetVisitorId(map);
6431 } 6459 }
6432 6460
6433 } // namespace internal 6461 } // namespace internal
6434 } // namespace v8 6462 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698