From patchwork Fri Mar 23 18:59:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Perez de Castro X-Patchwork-Id: 890153 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=igalia.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="I+CpSIdV"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 407CXr2BQ1z9s0b for ; Sat, 24 Mar 2018 06:00:28 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 5C3188A546; Fri, 23 Mar 2018 19:00:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BTSu96wD4QVq; Fri, 23 Mar 2018 19:00:18 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id AA2468A548; Fri, 23 Mar 2018 19:00:18 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 89B921CF0D4 for ; Fri, 23 Mar 2018 19:00:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8462C899B9 for ; Fri, 23 Mar 2018 19:00:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WuKMKOKx5QWQ for ; Fri, 23 Mar 2018 19:00:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fanzine.igalia.com (fanzine.igalia.com [91.117.99.155]) by whitealder.osuosl.org (Postfix) with ESMTPS id 2697D89995 for ; Fri, 23 Mar 2018 19:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=PPPDhhWdHYF3CRKzJOzdInMaaggwCoAkABSYo3yTmlE=; b=I+CpSIdVGLmoo4KBZlo0eK3ysQqs2a9jX2FJ+BM4XrYy93RfIt/EOdc14Ne5FbCYtccjuidZNT+dp45ufbsom2kO36nOZD56o8mUGN/bZQHKAkFinQr9rljRj3BPzuo/Hcacqj8xg8kCfH5d1SO09ZyBGgeogBr6eBSXoW8BqpNJSdqWUQQjYTE8wwcrkOpdapxVd2ru7JBdQtvDZr1WSUFW1qGySgV9Y/boUBMRcVE9jpZBXPUefgCIG7aqgzRFwyR8u/Ar2rWi92kieYpPrdB8olscaO6wOG1gLonLrk8icN2Jtv25D8Eb+W8zOxIhdIwcGHb91iDUbkcvN5yEMQ==; Received: from [194.100.51.2] (helo=kodama) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ezRv7-0000f4-7q; Fri, 23 Mar 2018 20:00:09 +0100 Received: from localhost (kodama [local]) by kodama (OpenSMTPD) with ESMTPA id 14cf945d; Fri, 23 Mar 2018 18:59:42 +0000 (UTC) From: Adrian Perez de Castro To: buildroot@buildroot.org Date: Fri, 23 Mar 2018 20:59:42 +0200 Message-Id: <20180323185942.60252-5-aperez@igalia.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323185942.60252-1-aperez@igalia.com> References: <20180323185942.60252-1-aperez@igalia.com> Subject: [Buildroot] [PATCH v2/next 4/4] webkitgtk: Add upstream patch for better memory monitoring X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Adrian Perez de Castro MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This imports a patch which has been committed upstream, but is not part of the 2.20.0 release which modifies WebKitGTK+'s memory monitor to take into account the available memory when calculating the thresholds at which the Web engine will try to return memory back to the system. The net result is that on constrained systems WebKitGTK+ will try to free memory it does not need more often. Signed-off-by: Adrian Perez de Castro --- ...memory-monitor-thresholds-should-be-bette.patch | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 package/webkitgtk/0001-WebProcess-memory-monitor-thresholds-should-be-bette.patch diff --git a/package/webkitgtk/0001-WebProcess-memory-monitor-thresholds-should-be-bette.patch b/package/webkitgtk/0001-WebProcess-memory-monitor-thresholds-should-be-bette.patch new file mode 100644 index 0000000000..9848ec8526 --- /dev/null +++ b/package/webkitgtk/0001-WebProcess-memory-monitor-thresholds-should-be-bette.patch @@ -0,0 +1,93 @@ +From 25fe9c19e4fb3519e34df7e16b3d761812b921aa Mon Sep 17 00:00:00 2001 +From: Adrian Perez de Castro +Date: Wed, 21 Mar 2018 01:05:53 +0200 +Subject: [PATCH xserver 1/2] WebProcess memory monitor thresholds should be + better tuned for embedded systems. + https://bugs.webkit.org/show_bug.cgi?id=183773 + +Patch by Carlos Alberto Lopez Perez on 2018-03-20 +Reviewed by NOBODY (OOPS!). + +Take into account the total system RAM for the thresholds calculation. + +For systems with more than 3GB the conservative and strict thresholds remain as they are, +but for systems with less RAM the thresholds are dynamically configured as follows: + +- Conservative threshold (release non critical memory) if WebProcess using more than 33% of the total RAM. +- Strict threshold (release all possible memory) if WebProcess using more than 50% of the total RAM. + +The Kill threshold is also modified. Now it is capped at 90% of the total RAM. + +* wtf/MemoryPressureHandler.cpp: +(WTF::thresholdForMemoryKillWithProcessState): +(WTF::thresholdForPolicy): +(WTF::MemoryPressureHandler::shrinkOrDie): + +Signed-off-by: Adrian Perez de Castro +Upstream-Status: Committed + +diff --git a/Source/WTF/wtf/MemoryPressureHandler.cpp b/Source/WTF/wtf/MemoryPressureHandler.cpp +index 0e1d1a60fe0..d31180883eb 100644 +--- a/Source/WTF/wtf/MemoryPressureHandler.cpp ++++ b/Source/WTF/wtf/MemoryPressureHandler.cpp +@@ -28,6 +28,7 @@ + + #include + #include ++#include + + #define LOG_CHANNEL_PREFIX Log + +@@ -84,20 +85,17 @@ static const char* toString(MemoryUsagePolicy policy) + + static size_t thresholdForMemoryKillWithProcessState(WebsamProcessState processState, unsigned tabCount) + { ++ size_t baseThreshold = 2 * GB; + #if CPU(X86_64) || CPU(ARM64) +- size_t baseThreshold; + if (processState == WebsamProcessState::Active) + baseThreshold = 4 * GB; +- else +- baseThreshold = 2 * GB; +- if (tabCount <= 1) +- return baseThreshold; +- return baseThreshold + (std::min(tabCount - 1, 4u) * 1 * GB); ++ if (tabCount > 1) ++ baseThreshold += std::min(tabCount - 1, 4u) * 1 * GB; + #else +- UNUSED_PARAM(processState); +- UNUSED_PARAM(tabCount); +- return 3 * GB; ++ if ((tabCount > 1) || (processState == WebsamProcessState::Active)) ++ baseThreshold = 3 * GB; + #endif ++ return std::min(baseThreshold, static_cast(ramSize() * 0.9)); + } + + void MemoryPressureHandler::setPageCount(unsigned pageCount) +@@ -114,11 +112,12 @@ size_t MemoryPressureHandler::thresholdForMemoryKill() + + static size_t thresholdForPolicy(MemoryUsagePolicy policy) + { ++ const size_t baseThresholdForPolicy = std::min(3 * GB, ramSize()); + switch (policy) { + case MemoryUsagePolicy::Conservative: +- return 1 * GB; ++ return baseThresholdForPolicy / 3; + case MemoryUsagePolicy::Strict: +- return 1.5 * GB; ++ return baseThresholdForPolicy / 2; + case MemoryUsagePolicy::Unrestricted: + default: + ASSERT_NOT_REACHED(); +@@ -150,6 +149,7 @@ void MemoryPressureHandler::shrinkOrDie() + return; + } + ++ WTFLogAlways("Unable to shrink memory footprint of process (%lu MB) below the kill thresold (%lu MB). Killed\n", footprint.value() / MB, thresholdForMemoryKill() / MB); + RELEASE_ASSERT(m_memoryKillCallback); + m_memoryKillCallback(); + } +-- +2.16.2 +