[M40 Merge][MEM OPT] Shrink v8 new space to initial capacity in NewSpace::Shrink
authorkriti.s <kriti.s@samsung.com>
Thu, 3 Dec 2015 06:12:21 +0000 (11:42 +0530)
committerYoungcheol Kang <ychul.kang@samsung.com>
Fri, 3 Jun 2016 08:25:13 +0000 (17:25 +0900)
Shrink v8 new space to initial capacity when NewSpace::Shrink is called.
Runtime flag: --js-flags="--shrink-new-space-to-initial-capacity=1"

Below are the memory reading with and without patch for sunspider.
Without patch(PSS)- 552781
WIth patch(PSS)- 535521

M40 patch: http://suprem.sec.samsung.net/gerrit/#/c/34431/

Signed-off-by: kriti.s <kriti.s@samsung.com>
Change-Id: Ia6ea517a631a2763118a9321b0d2cb7ba8327612

src/flag-definitions.h
src/heap/spaces.cc

index 654037c6e7d81ab35ead44641527957ce80a73c8..b1305517aefd47f90fb402d0df14c18db1bdd71a 100644 (file)
@@ -615,6 +615,8 @@ DEFINE_BOOL(experimental_new_space_growth_heuristic, false,
 DEFINE_INT(max_old_space_size, 0, "max size of the old space (in Mbytes)")
 DEFINE_INT(initial_old_space_size, 0, "initial old space size (in Mbytes)")
 DEFINE_INT(max_executable_size, 0, "max size of executable memory (in Mbytes)")
+DEFINE_INT(shrink_new_space_to_initial_capacity, 0,
+           "shrink new space to initial capacity")
 DEFINE_BOOL(gc_global, false, "always perform global GCs")
 DEFINE_INT(gc_interval, -1, "garbage collect after <n> allocations")
 DEFINE_INT(retain_maps_for_n_gc, 2,
index f6feaec8b788e84af801743ffb1306b639d4b4d2..391b86980b41df72663c8e99c852cfd5faebd015 100644 (file)
@@ -1368,6 +1368,10 @@ bool NewSpace::GrowOnePage() {
 
 void NewSpace::Shrink() {
   int new_capacity = Max(InitialTotalCapacity(), 2 * SizeAsInt());
+  //Overwrite new_capacity to shrink to initial capacity
+  //if shrink_new_space_to_initial_capacity flag is set
+  if (FLAG_shrink_new_space_to_initial_capacity)
+      new_capacity = InitialTotalCapacity();
   int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize);
   if (rounded_new_capacity < TotalCapacity() &&
       to_space_.ShrinkTo(rounded_new_capacity)) {