[M94 Migration][DA] Setting external memory limit 28/291228/4
authorjihwankim <jh_marc.kim@samsung.com>
Mon, 21 Jun 2021 06:54:47 +0000 (15:54 +0900)
committerBot Blink <blinkbot@samsung.com>
Fri, 21 Apr 2023 06:16:40 +0000 (06:16 +0000)
The value of external memory limit in V8 can be dynamically
changed during runtime. Sometimes, the limit can continuously
increase, so V8 can't call GC on proper time, resulting a steep
increment of the process memory in some cases.

This patch makes V8 GC not to increase the external_memory_limit
if GCCallbackFlag is not set to call Blink GC at the epilogue
stage of GC. In this way, the external_memory_limit value will
not increase in case of GC situations other than calling Blink
GC, so eventually GCs that calls Blink GC can be invoked soon.

Reference Patch : https://review.tizen.org/gerrit/#/c/253183/

Change-Id: I731e8b1b0ae143448b7163e6537eb3a6231bf078
Signed-off-by: jihwankim <jh_marc.kim@samsung.com>
v8/src/heap/heap.cc
v8/src/heap/heap.h

index 982b80bb89f765fb7be44ab2504a7c6ad066dbd3..0f786bb1448d23c5b8f82f415ffcb7ef9c7e21eb 100644 (file)
@@ -2268,7 +2268,11 @@ size_t Heap::PerformGarbageCollection(
   }
 #endif
 
+#if defined(OS_TIZEN_DA_PRODUCT)
+  RecomputeLimits(collector, gc_callback_flags);
+#else
   RecomputeLimits(collector);
+#endif
 
   GarbageCollectionEpilogueInSafepoint(collector);
 
@@ -2365,7 +2369,12 @@ void Heap::UpdateCurrentEpoch(GarbageCollector collector) {
 
 void Heap::UpdateEpochFull() { epoch_full_ = next_epoch(); }
 
+#if defined(OS_TIZEN_DA_PRODUCT)
+void Heap::RecomputeLimits(GarbageCollector collector,
+                           const v8::GCCallbackFlags gc_callback_flags) {
+#else
 void Heap::RecomputeLimits(GarbageCollector collector) {
+#endif
   if (!((collector == MARK_COMPACTOR) ||
         (HasLowYoungGenerationAllocationRate() &&
          old_generation_size_configured_))) {
@@ -2399,7 +2408,15 @@ void Heap::RecomputeLimits(GarbageCollector collector) {
   HeapGrowingMode mode = CurrentHeapGrowingMode();
 
   if (collector == MARK_COMPACTOR) {
+#if defined(OS_TIZEN_DA_PRODUCT)
+  if ((gc_callback_flags & kGCCallbackFlagForced) ||
+        (gc_callback_flags & kGCCallbackFlagCollectAllAvailableGarbage) ||
+        (gc_callback_flags & kGCCallbackFlagCollectAllExternalMemory)) {
     external_memory_.ResetAfterGC();
+        }
+#else
+    external_memory_.ResetAfterGC();
+#endif
 
     set_old_generation_allocation_limit(
         MemoryController<V8HeapTrait>::CalculateAllocationLimit(
index a752959d8abccc8e7c6db851e9ae8806a846180c..eacb79ddf8a5b20fcc7e0e68988c6dd4bdd806c4 100644 (file)
@@ -2071,8 +2071,12 @@ class Heap {
 
   base::Optional<size_t> GlobalMemoryAvailable();
 
+#if defined(OS_TIZEN_DA_PRODUCT)
+  void RecomputeLimits(GarbageCollector collector,
+                       const v8::GCCallbackFlags gc_callback_flags);
+#else
   void RecomputeLimits(GarbageCollector collector);
-
+#endif
   // ===========================================================================
   // Idle notification. ========================================================
   // ===========================================================================