208 lines
8.7 KiB
Diff
208 lines
8.7 KiB
Diff
From: uazo <uazo@users.noreply.github.com>
|
|
Date: Tue, 27 Jun 2023 11:11:53 +0000
|
|
Subject: Remove support for device memory and cpu recovery
|
|
|
|
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
|
|
---
|
|
.../browser/blob/blob_memory_controller.cc | 20 ++++++++++---------
|
|
.../browser/quota/quota_device_info_helper.cc | 17 ++++++++++++++--
|
|
.../approximated_device_memory.cc | 7 ++++++-
|
|
third_party/blink/common/features.cc | 4 ++--
|
|
.../frame/navigator_concurrent_hardware.cc | 8 ++++++--
|
|
.../blink/renderer/core/timing/memory_info.cc | 14 ++++++++++---
|
|
.../core/timing/window_performance.cc | 2 +-
|
|
7 files changed, 52 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/storage/browser/blob/blob_memory_controller.cc b/storage/browser/blob/blob_memory_controller.cc
|
|
--- a/storage/browser/blob/blob_memory_controller.cc
|
|
+++ b/storage/browser/blob/blob_memory_controller.cc
|
|
@@ -50,6 +50,15 @@ using MemoryAllocation = BlobMemoryController::MemoryAllocation;
|
|
using QuotaAllocationTask = BlobMemoryController::QuotaAllocationTask;
|
|
using DiskSpaceFuncPtr = BlobMemoryController::DiskSpaceFuncPtr;
|
|
|
|
+// static
|
|
+#if BUILDFLAG(IS_ANDROID)
|
|
+float approximated_device_memory_gb_ = 4.0;
|
|
+constexpr int64_t approximated_device_disk_size = 8ull * 1024 * 1024 * 1024;
|
|
+#else
|
|
+float approximated_device_memory_gb_ = 8.0;
|
|
+constexpr int64_t approximated_device_disk_size = 200ull * 1024 * 1024 * 1024;
|
|
+#endif
|
|
+
|
|
File::Error CreateBlobDirectory(const FilePath& blob_storage_dir) {
|
|
File::Error error = File::FILE_OK;
|
|
base::CreateDirectoryAndGetError(blob_storage_dir, &error);
|
|
@@ -79,23 +88,16 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(
|
|
int64_t disk_size = 0ull;
|
|
uint64_t memory_size = optional_memory_size_for_testing
|
|
? optional_memory_size_for_testing.value()
|
|
- : base::SysInfo::AmountOfPhysicalMemory();
|
|
+ : approximated_device_memory_gb_;
|
|
if (disk_enabled && CreateBlobDirectory(storage_dir) == base::File::FILE_OK)
|
|
- disk_size = base::SysInfo::AmountOfTotalDiskSpace(storage_dir);
|
|
+ disk_size = approximated_device_disk_size;
|
|
|
|
BlobStorageLimits limits;
|
|
|
|
// Don't do specialty configuration for error size (-1).
|
|
if (memory_size > 0) {
|
|
-#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) && \
|
|
- defined(ARCH_CPU_64_BITS)
|
|
constexpr size_t kTwoGigabytes = 2ull * 1024 * 1024 * 1024;
|
|
limits.max_blob_in_memory_space = kTwoGigabytes;
|
|
-#elif BUILDFLAG(IS_ANDROID)
|
|
- limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 100);
|
|
-#else
|
|
- limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5);
|
|
-#endif
|
|
}
|
|
// Devices just on the edge (RAM == 256MB) should not fail because
|
|
// max_blob_in_memory_space turns out smaller than min_page_file_size
|
|
diff --git a/storage/browser/quota/quota_device_info_helper.cc b/storage/browser/quota/quota_device_info_helper.cc
|
|
--- a/storage/browser/quota/quota_device_info_helper.cc
|
|
+++ b/storage/browser/quota/quota_device_info_helper.cc
|
|
@@ -8,17 +8,30 @@
|
|
|
|
namespace storage {
|
|
|
|
+namespace {
|
|
+
|
|
+// static
|
|
+#if BUILDFLAG(IS_ANDROID)
|
|
+float approximated_device_memory_gb_ = 4.0;
|
|
+constexpr int64_t approximated_device_disk_size = 8ull * 1024 * 1024 * 1024;
|
|
+#else
|
|
+float approximated_device_memory_gb_ = 8.0;
|
|
+constexpr int64_t approximated_device_disk_size = 200ull * 1024 * 1024 * 1024;
|
|
+#endif
|
|
+
|
|
+}
|
|
+
|
|
QuotaDeviceInfoHelper::~QuotaDeviceInfoHelper() = default;
|
|
|
|
int64_t QuotaDeviceInfoHelper::AmountOfTotalDiskSpace(
|
|
const base::FilePath& path) const {
|
|
- int64_t disk_space = base::SysInfo::AmountOfTotalDiskSpace(path);
|
|
+ int64_t disk_space = approximated_device_disk_size;
|
|
UMA_HISTOGRAM_BOOLEAN("Quota.TotalDiskSpaceIsZero", disk_space <= 0);
|
|
return disk_space;
|
|
}
|
|
|
|
uint64_t QuotaDeviceInfoHelper::AmountOfPhysicalMemory() const {
|
|
- return base::SysInfo::AmountOfPhysicalMemory();
|
|
+ return approximated_device_memory_gb_;
|
|
}
|
|
|
|
} // namespace storage
|
|
diff --git a/third_party/blink/common/device_memory/approximated_device_memory.cc b/third_party/blink/common/device_memory/approximated_device_memory.cc
|
|
--- a/third_party/blink/common/device_memory/approximated_device_memory.cc
|
|
+++ b/third_party/blink/common/device_memory/approximated_device_memory.cc
|
|
@@ -4,13 +4,18 @@
|
|
|
|
#include "third_party/blink/public/common/device_memory/approximated_device_memory.h"
|
|
|
|
+#include "build/build_config.h"
|
|
#include "base/check_op.h"
|
|
#include "base/system/sys_info.h"
|
|
|
|
namespace blink {
|
|
|
|
// static
|
|
-float ApproximatedDeviceMemory::approximated_device_memory_gb_ = 0.0;
|
|
+#if BUILDFLAG(IS_ANDROID)
|
|
+float ApproximatedDeviceMemory::approximated_device_memory_gb_ = 4.0;
|
|
+#else
|
|
+float ApproximatedDeviceMemory::approximated_device_memory_gb_ = 8.0;
|
|
+#endif
|
|
int64_t ApproximatedDeviceMemory::physical_memory_mb_ = 0;
|
|
|
|
// static
|
|
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
|
|
--- a/third_party/blink/common/features.cc
|
|
+++ b/third_party/blink/common/features.cc
|
|
@@ -2034,8 +2034,8 @@ BASE_FEATURE(kWebFontsCacheAwareTimeoutAdaption,
|
|
// Controls whether the implementation of the performance.measureMemory
|
|
// web API uses PerformanceManager or not.
|
|
BASE_FEATURE(kWebMeasureMemoryViaPerformanceManager,
|
|
- "WebMeasureMemoryViaPerformanceManager",
|
|
- base::FEATURE_ENABLED_BY_DEFAULT);
|
|
+ "WebMeasureMemoryViaPerformanceManager", // need to be
|
|
+ base::FEATURE_DISABLED_BY_DEFAULT); // disabled by default
|
|
|
|
BASE_FEATURE(kWebRtcCombinedNetworkAndWorkerThread,
|
|
"WebRtcCombinedNetworkAndWorkerThread",
|
|
diff --git a/third_party/blink/renderer/core/frame/navigator_concurrent_hardware.cc b/third_party/blink/renderer/core/frame/navigator_concurrent_hardware.cc
|
|
--- a/third_party/blink/renderer/core/frame/navigator_concurrent_hardware.cc
|
|
+++ b/third_party/blink/renderer/core/frame/navigator_concurrent_hardware.cc
|
|
@@ -3,13 +3,17 @@
|
|
// found in the LICENSE file.
|
|
|
|
#include "third_party/blink/renderer/core/frame/navigator_concurrent_hardware.h"
|
|
-
|
|
+#include "build/build_config.h"
|
|
#include "base/system/sys_info.h"
|
|
|
|
namespace blink {
|
|
|
|
unsigned NavigatorConcurrentHardware::hardwareConcurrency() const {
|
|
- return static_cast<unsigned>(base::SysInfo::NumberOfProcessors());
|
|
+#if BUILDFLAG(IS_ANDROID)
|
|
+ return static_cast<unsigned>(2);
|
|
+#else
|
|
+ return static_cast<unsigned>(8);
|
|
+#endif
|
|
}
|
|
|
|
} // namespace blink
|
|
diff --git a/third_party/blink/renderer/core/timing/memory_info.cc b/third_party/blink/renderer/core/timing/memory_info.cc
|
|
--- a/third_party/blink/renderer/core/timing/memory_info.cc
|
|
+++ b/third_party/blink/renderer/core/timing/memory_info.cc
|
|
@@ -34,6 +34,8 @@
|
|
|
|
#include "base/time/default_tick_clock.h"
|
|
#include "base/time/time.h"
|
|
+#include "base/rand_util.h"
|
|
+#include "build/build_config.h"
|
|
#include "third_party/blink/renderer/core/frame/settings.h"
|
|
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
|
|
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
|
|
@@ -43,15 +45,21 @@ namespace blink {
|
|
|
|
static constexpr base::TimeDelta kTwentyMinutes = base::Minutes(20);
|
|
static constexpr base::TimeDelta kFiftyMs = base::Milliseconds(50);
|
|
+#if BUILDFLAG(IS_ANDROID)
|
|
+static constexpr int64_t heap_size_limit = 528744448;
|
|
+#else
|
|
+static constexpr int64_t heap_size_limit = 4294705152;
|
|
+#endif
|
|
|
|
static void GetHeapSize(HeapInfo& info) {
|
|
v8::HeapStatistics heap_statistics;
|
|
v8::Isolate::GetCurrent()->GetHeapStatistics(&heap_statistics);
|
|
+ const double scale_factor = 1.0 + base::RandInt(-300, 300) / 10000.0;
|
|
info.used_js_heap_size =
|
|
- heap_statistics.used_heap_size() + heap_statistics.external_memory();
|
|
+ (heap_statistics.used_heap_size() + heap_statistics.external_memory()) * scale_factor;
|
|
info.total_js_heap_size =
|
|
- heap_statistics.total_physical_size() + heap_statistics.external_memory();
|
|
- info.js_heap_size_limit = heap_statistics.heap_size_limit();
|
|
+ (heap_statistics.total_physical_size() + heap_statistics.external_memory()) * scale_factor;
|
|
+ info.js_heap_size_limit = heap_size_limit;
|
|
}
|
|
|
|
class HeapSizeCache {
|
|
diff --git a/third_party/blink/renderer/core/timing/window_performance.cc b/third_party/blink/renderer/core/timing/window_performance.cc
|
|
--- a/third_party/blink/renderer/core/timing/window_performance.cc
|
|
+++ b/third_party/blink/renderer/core/timing/window_performance.cc
|
|
@@ -255,7 +255,7 @@ MemoryInfo* WindowPerformance::memory(ScriptState* script_state) const {
|
|
auto* memory_info = MakeGarbageCollected<MemoryInfo>(
|
|
Platform::Current()->IsLockedToSite()
|
|
? MemoryInfo::Precision::kPrecise
|
|
- : MemoryInfo::Precision::kBucketized);
|
|
+ : MemoryInfo::Precision::kPrecise);
|
|
// Record Web Memory UKM.
|
|
const uint64_t kBytesInKB = 1024;
|
|
auto* execution_context = ExecutionContext::From(script_state);
|
|
--
|
|
2.25.1
|