From: Bakka Uday Kiran Date: Fri, 10 Feb 2023 11:56:22 +0000 (+0530) Subject: [M108 Migration] Add discardable memory and purge delay switch X-Git-Tag: submit/tizen/20230227.160252~81 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6919fae13e041f6c661df0549843e8d117a73613;p=platform%2Fframework%2Fweb%2Fchromium-efl.git [M108 Migration] Add discardable memory and purge delay switch This commit enables to manually configure discardable memory and purge delay from command line. Reference: https://review.tizen.org/gerrit/c/280812 Change-Id: I941092fb926cb2ec9bfdc87c5eaa2127e01e7d00 Signed-off-by: Bakka Uday Kiran --- diff --git a/base/base_switches.cc b/base/base_switches.cc index a4c6baf6d496..ac811c0a1608 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -150,6 +150,11 @@ const char kLimitMemoryAllocationInScheduleDelayedWork[] = const char kEnableOffscreenRendering[] = "enable-offscreen-rendering"; #endif +#if BUILDFLAG(IS_TIZEN) +const char kDiscardableMemoryLimit[] = "discardable-memory-limit"; +const char kDiscardableMemoryPurgeDelay[] = "discardable-memory-purge-delay"; +#endif + #if BUILDFLAG(IS_POSIX) // Used for turning on Breakpad crash reporting in a debug environment where // crash reporting is typically compiled but disabled. diff --git a/base/base_switches.h b/base/base_switches.h index 29a95cf6cde4..7b0d90f60cc1 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -53,6 +53,11 @@ extern const char kLimitMemoryAllocationInScheduleDelayedWork[]; extern const char kEnableOffscreenRendering[]; #endif +#if BUILDFLAG(IS_TIZEN) +extern const char kDiscardableMemoryLimit[]; +extern const char kDiscardableMemoryPurgeDelay[]; +#endif + #if BUILDFLAG(IS_POSIX) extern const char kEnableCrashReporterForTesting[]; #endif diff --git a/components/discardable_memory/service/discardable_shared_memory_manager.cc b/components/discardable_memory/service/discardable_shared_memory_manager.cc index 20907461c37f..cfabfe0cf070 100644 --- a/components/discardable_memory/service/discardable_shared_memory_manager.cc +++ b/components/discardable_memory/service/discardable_shared_memory_manager.cc @@ -38,6 +38,10 @@ #include "base/metrics/histogram_macros.h" #endif +#if BUILDFLAG(IS_TIZEN) +#include "base/base_switches.h" +#endif + namespace discardable_memory { namespace { @@ -242,6 +246,26 @@ DiscardableSharedMemoryManager::DiscardableSharedMemoryManager() DCHECK(!g_instance) << "A DiscardableSharedMemoryManager already exists in this process."; g_instance = this; + +#if BUILDFLAG(IS_TIZEN) + std::string switch_value = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kDiscardableMemoryLimit); + size_t discardable_mem_limit; + if (base::StringToSizeT(switch_value, &discardable_mem_limit)) + memory_limit_ = discardable_mem_limit * 1024 * 1024; + + std::string delay_value = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kDiscardableMemoryPurgeDelay); + int discardable_mem_purge_delay; + if (base::StringToInt(delay_value, &discardable_mem_purge_delay)) + purge_delay_ = base::Milliseconds(discardable_mem_purge_delay); + + LOG(INFO) << "DiscardableMemoryLimit : " << memory_limit_ / 1024 << "KB"; + LOG(INFO) << "DiscardableMemoryPurgeDelay : " << purge_delay_; +#endif + DCHECK_NE(memory_limit_, 0u); enforce_memory_policy_callback_ = base::BindRepeating(&DiscardableSharedMemoryManager::EnforceMemoryPolicy, @@ -569,7 +593,12 @@ void DiscardableSharedMemoryManager::ReduceMemoryUsageUntilWithinLimit( break; // Stop eviction attempts when the LRU segment is currently in use. +#if BUILDFLAG(IS_TIZEN) + if (segments_.front()->memory()->last_known_usage() + purge_delay_ >= + current_time) +#else if (segments_.front()->memory()->last_known_usage() >= current_time) +#endif break; std::pop_heap(segments_.begin(), segments_.end(), CompareMemoryUsageTime); diff --git a/components/discardable_memory/service/discardable_shared_memory_manager.h b/components/discardable_memory/service/discardable_shared_memory_manager.h index 09ea87363dc4..26e8e5798522 100644 --- a/components/discardable_memory/service/discardable_shared_memory_manager.h +++ b/components/discardable_memory/service/discardable_shared_memory_manager.h @@ -186,6 +186,10 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager base::WeakPtrFactory weak_ptr_factory_{this}; +#if BUILDFLAG(IS_TIZEN) + base::TimeDelta purge_delay_; +#endif + // WeakPtrFractory for generating weak pointers used in the mojo thread. base::WeakPtrFactory mojo_thread_weak_ptr_factory_{this}; diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index e2ff206c94a0..64796dfc91c0 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -3438,6 +3438,10 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( #endif #if BUILDFLAG(IS_EFL) autofill::switches::kDisableAutofill, +#endif +#if BUILDFLAG(IS_TIZEN) + switches::kDiscardableMemoryLimit, + switches::kDiscardableMemoryPurgeDelay, #endif }; renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, diff --git a/tizen_src/ewk/efl_integration/command_line_efl.cc b/tizen_src/ewk/efl_integration/command_line_efl.cc index 3e21479d5399..eddd778ac989 100644 --- a/tizen_src/ewk/efl_integration/command_line_efl.cc +++ b/tizen_src/ewk/efl_integration/command_line_efl.cc @@ -76,7 +76,15 @@ content::MainFunctionParams CommandLineEfl::GetDefaultPortParams() { #endif #if BUILDFLAG(IS_TIZEN) -#if !defined(EWK_BRINGUP) // FIXME:m85 bringup + // For optimizing discardable memory. [limit:MB, delay:ms] + if (!p_command_line->HasSwitch(switches::kDiscardableMemoryLimit)) + p_command_line->AppendSwitchASCII(switches::kDiscardableMemoryLimit, "20"); + + if (!p_command_line->HasSwitch(switches::kDiscardableMemoryPurgeDelay)) { + p_command_line->AppendSwitchASCII(switches::kDiscardableMemoryPurgeDelay, + "500"); + } +#if !defined(EWK_BRINGUP) p_command_line->AppendSwitchASCII( switches::kAcceleratedCanvas2dMSAASampleCount, "4"); p_command_line->AppendSwitch(switches::kEnableGestureTapHighlight);