Commit cf748365 authored by Zhi An Ng's avatar Zhi An Ng Committed by Commit Bot

Revert "[heap] Skip memory reducer on AdjustAmountOfExternalAllocateMemory"

This reverts commit 7ae30cb7.

Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Presubmit/10185

Original change's description:
> [heap] Skip memory reducer on AdjustAmountOfExternalAllocateMemory
> 
> V8 performs GC based on external memory limit. Additionally triggering
> memory reducing GCs may be problematic for large heaps and increases
> the chances of multiple V8 isolates performing GCs after
> IsolateInBackgroundNotification.
> 
> Bug: chromium:1072746
> 
> Change-Id: I7649a176504803ba666e6367b008593bbcfe6312
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2159488
> Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Hannes Payer <hpayer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67398}

TBR=ulan@chromium.org,hpayer@chromium.org,mlippautz@chromium.org

Change-Id: I008b1a0db2b4902190a6fa7e0861b5366f25b7fd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1072746
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2168113Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67400}
parent 054f5f69
......@@ -24,9 +24,9 @@
#include <utility>
#include <vector>
#include "v8-internal.h" // NOLINT(build/include_directory)
#include "v8-version.h" // NOLINT(build/include_directory)
#include "v8config.h" // NOLINT(build/include_directory)
#include "v8-internal.h" // NOLINT(build/include)
#include "v8-version.h" // NOLINT(build/include)
#include "v8config.h" // NOLINT(build/include)
// We reserve the V8_* prefix for macros defined in V8 public API and
// assume there are no name conflicts with the embedder's code.
......@@ -9530,6 +9530,7 @@ class V8_EXPORT Isolate {
internal::Address* GetDataFromSnapshotOnce(size_t index);
void ReportExternalAllocationLimitReached();
void CheckMemoryPressure();
};
class V8_EXPORT StartupData {
......@@ -11967,6 +11968,7 @@ MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes) {
typedef internal::Internals I;
constexpr int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
int64_t* external_memory = reinterpret_cast<int64_t*>(
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
......@@ -11989,6 +11991,14 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
if (change_in_bytes <= 0) return *external_memory;
int64_t allocation_diff_since_last_mc = static_cast<int64_t>(
static_cast<uint64_t>(*external_memory) -
static_cast<uint64_t>(*external_memory_low_since_mc));
// Only check memory pressure and potentially trigger GC if the amount of
// external memory increased.
if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
CheckMemoryPressure();
}
if (amount > *external_memory_limit) {
ReportExternalAllocationLimitReached();
}
......
......@@ -8038,6 +8038,12 @@ void Isolate::ReportExternalAllocationLimitReached() {
heap->ReportExternalMemoryPressure();
}
void Isolate::CheckMemoryPressure() {
i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
if (heap->gc_state() != i::Heap::NOT_IN_GC) return;
heap->CheckMemoryPressure();
}
HeapProfiler* Isolate::GetHeapProfiler() {
i::HeapProfiler* heap_profiler =
reinterpret_cast<i::Isolate*>(this)->heap_profiler();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment