mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 22:28:51 +02:00
deps: V8: cherry-pick 502c6ae6 from upstream
Original commit message: [heap] Activate memory reducer on external memory activity. BUG=chromium:728228,chromium:626082 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng Review-Url: https://codereview.chromium.org/2917853004 Cr-Commit-Position: refs/heads/master@{#45671} PR-URL: https://github.com/nodejs/node/pull/21269 Fixes: https://github.com/nodejs/node/issues/21021 Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
parent
020057ade7
commit
d868eb784c
5 changed files with 32 additions and 5 deletions
2
deps/v8/include/v8-version.h
vendored
2
deps/v8/include/v8-version.h
vendored
|
@ -11,7 +11,7 @@
|
||||||
#define V8_MAJOR_VERSION 6
|
#define V8_MAJOR_VERSION 6
|
||||||
#define V8_MINOR_VERSION 2
|
#define V8_MINOR_VERSION 2
|
||||||
#define V8_BUILD_NUMBER 414
|
#define V8_BUILD_NUMBER 414
|
||||||
#define V8_PATCH_LEVEL 55
|
#define V8_PATCH_LEVEL 56
|
||||||
|
|
||||||
// Use 1 for candidates and 0 otherwise.
|
// Use 1 for candidates and 0 otherwise.
|
||||||
// (Boolean macro values are not supported by all preprocessors.)
|
// (Boolean macro values are not supported by all preprocessors.)
|
||||||
|
|
18
deps/v8/include/v8.h
vendored
18
deps/v8/include/v8.h
vendored
|
@ -7770,6 +7770,7 @@ class V8_EXPORT Isolate {
|
||||||
friend class PersistentValueMapBase;
|
friend class PersistentValueMapBase;
|
||||||
|
|
||||||
void ReportExternalAllocationLimitReached();
|
void ReportExternalAllocationLimitReached();
|
||||||
|
void CheckMemoryPressure();
|
||||||
};
|
};
|
||||||
|
|
||||||
class V8_EXPORT StartupData {
|
class V8_EXPORT StartupData {
|
||||||
|
@ -9019,6 +9020,8 @@ class Internals {
|
||||||
static const int kExternalMemoryOffset = 4 * kApiPointerSize;
|
static const int kExternalMemoryOffset = 4 * kApiPointerSize;
|
||||||
static const int kExternalMemoryLimitOffset =
|
static const int kExternalMemoryLimitOffset =
|
||||||
kExternalMemoryOffset + kApiInt64Size;
|
kExternalMemoryOffset + kApiInt64Size;
|
||||||
|
static const int kExternalMemoryAtLastMarkCompactOffset =
|
||||||
|
kExternalMemoryLimitOffset + kApiInt64Size;
|
||||||
static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
|
static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
|
||||||
kApiInt64Size + kApiInt64Size +
|
kApiInt64Size + kApiInt64Size +
|
||||||
kApiPointerSize + kApiPointerSize;
|
kApiPointerSize + kApiPointerSize;
|
||||||
|
@ -10244,13 +10247,28 @@ uint32_t Isolate::GetNumberOfDataSlots() {
|
||||||
|
|
||||||
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
||||||
int64_t change_in_bytes) {
|
int64_t change_in_bytes) {
|
||||||
|
const int64_t kMemoryReducerActivationLimit = 1024 * 1024;
|
||||||
typedef internal::Internals I;
|
typedef internal::Internals I;
|
||||||
int64_t* external_memory = reinterpret_cast<int64_t*>(
|
int64_t* external_memory = reinterpret_cast<int64_t*>(
|
||||||
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
||||||
const int64_t external_memory_limit = *reinterpret_cast<int64_t*>(
|
const int64_t external_memory_limit = *reinterpret_cast<int64_t*>(
|
||||||
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
|
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
|
||||||
|
int64_t* external_memory_at_last_mc =
|
||||||
|
reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
|
||||||
|
I::kExternalMemoryAtLastMarkCompactOffset);
|
||||||
const int64_t amount = *external_memory + change_in_bytes;
|
const int64_t amount = *external_memory + change_in_bytes;
|
||||||
|
|
||||||
*external_memory = amount;
|
*external_memory = amount;
|
||||||
|
|
||||||
|
int64_t allocation_diff_since_last_mc =
|
||||||
|
*external_memory_at_last_mc - *external_memory;
|
||||||
|
allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
|
||||||
|
? -allocation_diff_since_last_mc
|
||||||
|
: allocation_diff_since_last_mc;
|
||||||
|
if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
|
||||||
|
CheckMemoryPressure();
|
||||||
|
}
|
||||||
|
|
||||||
if (change_in_bytes > 0 && amount > external_memory_limit) {
|
if (change_in_bytes > 0 && amount > external_memory_limit) {
|
||||||
ReportExternalAllocationLimitReached();
|
ReportExternalAllocationLimitReached();
|
||||||
}
|
}
|
||||||
|
|
4
deps/v8/src/api.cc
vendored
4
deps/v8/src/api.cc
vendored
|
@ -8405,6 +8405,10 @@ void Isolate::ReportExternalAllocationLimitReached() {
|
||||||
heap->ReportExternalMemoryPressure();
|
heap->ReportExternalMemoryPressure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Isolate::CheckMemoryPressure() {
|
||||||
|
i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
|
||||||
|
heap->CheckMemoryPressure();
|
||||||
|
}
|
||||||
|
|
||||||
HeapProfiler* Isolate::GetHeapProfiler() {
|
HeapProfiler* Isolate::GetHeapProfiler() {
|
||||||
i::HeapProfiler* heap_profiler =
|
i::HeapProfiler* heap_profiler =
|
||||||
|
|
2
deps/v8/src/heap/heap.cc
vendored
2
deps/v8/src/heap/heap.cc
vendored
|
@ -4816,10 +4816,12 @@ void Heap::CheckMemoryPressure() {
|
||||||
GarbageCollectionReason::kMemoryPressure);
|
GarbageCollectionReason::kMemoryPressure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (memory_reducer_) {
|
||||||
MemoryReducer::Event event;
|
MemoryReducer::Event event;
|
||||||
event.type = MemoryReducer::kPossibleGarbage;
|
event.type = MemoryReducer::kPossibleGarbage;
|
||||||
event.time_ms = MonotonicallyIncreasingTimeInMs();
|
event.time_ms = MonotonicallyIncreasingTimeInMs();
|
||||||
memory_reducer_->NotifyPossibleGarbage(event);
|
memory_reducer_->NotifyPossibleGarbage(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Heap::CollectGarbageOnMemoryPressure() {
|
void Heap::CollectGarbageOnMemoryPressure() {
|
||||||
|
|
3
deps/v8/src/isolate.cc
vendored
3
deps/v8/src/isolate.cc
vendored
|
@ -2837,6 +2837,9 @@ bool Isolate::Init(StartupDeserializer* des) {
|
||||||
Internals::kExternalMemoryOffset);
|
Internals::kExternalMemoryOffset);
|
||||||
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.external_memory_limit_)),
|
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.external_memory_limit_)),
|
||||||
Internals::kExternalMemoryLimitOffset);
|
Internals::kExternalMemoryLimitOffset);
|
||||||
|
CHECK_EQ(static_cast<int>(
|
||||||
|
OFFSET_OF(Isolate, heap_.external_memory_at_last_mark_compact_)),
|
||||||
|
Internals::kExternalMemoryAtLastMarkCompactOffset);
|
||||||
|
|
||||||
time_millis_at_init_ = heap_.MonotonicallyIncreasingTimeInMs();
|
time_millis_at_init_ = heap_.MonotonicallyIncreasingTimeInMs();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue