From 9c428da53ab403725c78862d34a8da2b14e69494 Mon Sep 17 00:00:00 2001 From: "kriti.s" Date: Thu, 3 Dec 2015 11:42:21 +0530 Subject: [PATCH] [M40 Merge][MEM OPT] Shrink v8 new space to initial capacity in NewSpace::Shrink 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 Change-Id: Ia6ea517a631a2763118a9321b0d2cb7ba8327612 --- src/flag-definitions.h | 2 ++ src/heap/spaces.cc | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 654037c6e..b1305517a 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -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 allocations") DEFINE_INT(retain_maps_for_n_gc, 2, diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc index f6feaec8b..391b86980 100644 --- a/src/heap/spaces.cc +++ b/src/heap/spaces.cc @@ -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)) { -- 2.34.1