Reduce the in-memory blob storgae limit on Android
BUG=715859 Review-Url: https://codereview.chromium.org/2855943003 Cr-Commit-Position: refs/heads/master@{#469550}
This commit is contained in:
content
storage
@@ -494,10 +494,10 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, BlobsCountAgainstQuota) {
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DeleteForOriginDeletesBlobs) {
|
||||
SimpleTest(GetTestUrl("indexeddb", "write_20mb_blob.html"));
|
||||
SimpleTest(GetTestUrl("indexeddb", "write_4mb_blob.html"));
|
||||
int64_t size = RequestDiskUsage();
|
||||
// This assertion assumes that we do not compress blobs.
|
||||
EXPECT_GT(size, 20 << 20 /* 20 MB */);
|
||||
EXPECT_GT(size, 4 << 20 /* 4 MB */);
|
||||
// TODO(jsbell): Remove static_cast<> when overloads are eliminated.
|
||||
GetContext()->TaskRunner()->PostTask(
|
||||
FROM_HERE,
|
||||
|
@@ -13,7 +13,7 @@
|
||||
// Constants.
|
||||
var store_name = 'blobs_use_space';
|
||||
var blob_key = 'blob_key';
|
||||
var blob_size = 20 * 1024 * 1024;
|
||||
var blob_size = 4 * 1024 * 1024;
|
||||
|
||||
// Shared variables.
|
||||
var db;
|
||||
|
4
content/test/data/indexeddb/write_20mb_blob.html → content/test/data/indexeddb/write_4mb_blob.html
4
content/test/data/indexeddb/write_20mb_blob.html → content/test/data/indexeddb/write_4mb_blob.html
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
@@ -13,7 +13,7 @@
|
||||
// Constants.
|
||||
var store_name = 'blobs';
|
||||
var blob_key = 'blob_key';
|
||||
var blob_size = 20 * 1024 * 1024; // 20MB
|
||||
var blob_size = 4 * 1024 * 1024; // 4MB
|
||||
|
||||
// Shared variables.
|
||||
var db;
|
@@ -82,12 +82,14 @@ https://cs.chromium.org/chromium/src/storage/browser/blob/blob_memory_controller
|
||||
**In-Memory Storage Limit**
|
||||
|
||||
* If the architecture is x64 and NOT Chrome OS or Android: `2GB`
|
||||
* Otherwise: `total_physical_memory / 5`
|
||||
* If Chrome OS: `total_physical_memory / 5`
|
||||
* If Android: `total_physical_memory / 100`
|
||||
|
||||
|
||||
**Disk Storage Limit**
|
||||
|
||||
* If Chrome OS: `disk_size / 2`
|
||||
* If Android: `disk_size / 20`
|
||||
* If Android: `6 * disk_size / 100`
|
||||
* Else: `disk_size / 10`
|
||||
|
||||
Note: Chrome OS's disk is part of the user partition, which is separate from the
|
||||
@@ -102,16 +104,14 @@ we use is:
|
||||
|
||||
## Example Limits
|
||||
|
||||
(All sizes in GB)
|
||||
|
||||
| Device | Ram | In-Memory Limit | Disk | Disk Limit | Min Disk Availability |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| Cast | 0.5 | 0.1 | 0 | 0 | 0 |
|
||||
| Android Minimal | 0.5 | 0.1 | 8 | 0.4 | 0.2 |
|
||||
| Android Fat | 2 | 0.4 | 32 | 1.5 | 0.8 |
|
||||
| CrOS | 2 | 0.4 | 8 | 4 | 0.8 |
|
||||
| Desktop 32 | 3 | 0.6 | 500 | 50 | 1.2 |
|
||||
| Desktop 64 | 4 | 2 | 500 | 50 | 4 |
|
||||
| Cast | 512 MB | 102 MB | 0 | 0 | 0 |
|
||||
| Android Minimal | 512 MB | 5 MB | 8 GB | 491 MB | 10 MB |
|
||||
| Android Fat | 2 GB | 20 MB | 32 GB | 1.9 GB | 40 MB |
|
||||
| CrOS | 2 GB | 409 MB | 8 GB | 4 GB | 0.8 GB |
|
||||
| Desktop 32 | 3 GB | 614 MB | 500 GB | 50 GB | 1.2 GB |
|
||||
| Desktop 64 | 4 GB | 2 GB | 500 GB | 50 GB | 4 GB |
|
||||
|
||||
# Common Pitfalls
|
||||
|
||||
@@ -128,7 +128,7 @@ the renderer can get rid of the data.
|
||||
## Leaking Blob References
|
||||
|
||||
If the blob object in Javascript is kept around, then the data will never be
|
||||
cleaned up in the backend. This will unnecessarily us memory, so make sure to
|
||||
cleaned up in the backend. This will unnecessarily use memory, so make sure to
|
||||
dereference blob objects if they are no longer needed.
|
||||
|
||||
Similarily if a URL is created for a blob, this will keep the blob data around
|
||||
|
@@ -53,8 +53,8 @@ using DiskSpaceFuncPtr = BlobMemoryController::DiskSpaceFuncPtr;
|
||||
// Note: The disk is the user partition, so the operating system can still
|
||||
// function if this is full.
|
||||
// Android:
|
||||
// * RAM - 20%
|
||||
// * Disk - 5%
|
||||
// * RAM - 1%
|
||||
// * Disk - 6%
|
||||
// Desktop:
|
||||
// * Ram - 20%, or 2 GB if x64.
|
||||
// * Disk - 10%
|
||||
@@ -71,6 +71,8 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir,
|
||||
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && defined(ARCH_CPU_64_BITS)
|
||||
constexpr size_t kTwoGigabytes = 2ull * 1024 * 1024 * 1024;
|
||||
limits.max_blob_in_memory_space = kTwoGigabytes;
|
||||
#elif defined(OS_ANDROID)
|
||||
limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 100ll);
|
||||
#else
|
||||
limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5ll);
|
||||
#endif
|
||||
@@ -81,7 +83,7 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir,
|
||||
#if defined(OS_CHROMEOS)
|
||||
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 2ll);
|
||||
#elif defined(OS_ANDROID)
|
||||
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 20ll);
|
||||
limits.desired_max_disk_space = static_cast<uint64_t>(3ll * disk_size / 50);
|
||||
#else
|
||||
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 10ll);
|
||||
#endif
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/callback_forward.h"
|
||||
#include "build/build_config.h"
|
||||
#include "storage/common/storage_common_export.h"
|
||||
|
||||
namespace storage {
|
||||
@@ -17,9 +18,15 @@ constexpr size_t kDefaultIPCMemorySize = 250u * 1024;
|
||||
constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024;
|
||||
constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024;
|
||||
constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull;
|
||||
constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024;
|
||||
constexpr uint64_t kDefaultMaxPageFileSize = 100ull * 1024 * 1024;
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
// On minimal Android maximum in-memory space can be as low as 5MB.
|
||||
constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024 / 2;
|
||||
#else
|
||||
constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024;
|
||||
#endif
|
||||
|
||||
// All sizes are in bytes.
|
||||
struct STORAGE_COMMON_EXPORT BlobStorageLimits {
|
||||
// Returns if the current configuration is valid.
|
||||
|
Reference in New Issue
Block a user