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

Unified Diff: src/heap/heap.cc

Issue 2256853003: [heap] Introduce hard limit for external memory (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index ae9f4fd71ce0e88a25167112279a7cc1d5d54de6..fab79ddb71b30ed39cc26e521de7ee3116db7eac 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -71,7 +71,7 @@ class IdleScavengeObserver : public AllocationObserver {
Heap::Heap()
: external_memory_(0),
- external_memory_limit_(kExternalAllocationLimit),
+ external_memory_limit_(kExternalAllocationSoftLimit),
external_memory_at_last_mark_compact_(0),
isolate_(nullptr),
code_range_size_(0),
@@ -903,6 +903,14 @@ void Heap::CollectAllAvailableGarbage(const char* gc_reason) {
void Heap::ReportExternalMemoryPressure(const char* gc_reason) {
+ if (external_memory_ >
+ (external_memory_at_last_mark_compact_ + external_memory_hard_limit())) {
+ CollectAllGarbage(
+ kReduceMemoryFootprintMask | kFinalizeIncrementalMarkingMask, gc_reason,
+ static_cast<GCCallbackFlags>(kGCCallbackFlagCollectAllAvailableGarbage |
+ kGCCallbackFlagCollectAllExternalMemory));
+ return;
+ }
if (incremental_marking()->IsStopped()) {
if (incremental_marking()->CanBeActivated()) {
StartIncrementalMarking(
@@ -917,11 +925,15 @@ void Heap::ReportExternalMemoryPressure(const char* gc_reason) {
}
} else {
// Incremental marking is turned on an has already been started.
-
- // TODO(mlippautz): Compute the time slice for incremental marking based on
- // memory pressure.
- double deadline = MonotonicallyIncreasingTimeInMs() +
- FLAG_external_allocation_limit_incremental_time;
+ const double pressure =
+ static_cast<double>(external_memory_ -
+ external_memory_at_last_mark_compact_ -
+ kExternalAllocationSoftLimit) /
+ external_memory_hard_limit();
+ DCHECK_GE(1, pressure);
+ const double kMaxStepSizeOnExternalLimit = 25;
+ const double deadline = MonotonicallyIncreasingTimeInMs() +
+ pressure * kMaxStepSizeOnExternalLimit;
incremental_marking()->AdvanceIncrementalMarking(
deadline,
IncrementalMarking::StepActions(IncrementalMarking::GC_VIA_STACK_GUARD,
@@ -1362,7 +1374,7 @@ bool Heap::PerformGarbageCollection(
if (collector == MARK_COMPACTOR) {
// Register the amount of external allocated memory.
external_memory_at_last_mark_compact_ = external_memory_;
- external_memory_limit_ = external_memory_ + kExternalAllocationLimit;
+ external_memory_limit_ = external_memory_ + kExternalAllocationSoftLimit;
SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed);
} else if (HasLowYoungGenerationAllocationRate() &&
old_generation_size_configured_) {
« no previous file with comments | « src/heap/heap.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698