Commit 81a539c7 authored by ssid's avatar ssid Committed by Commit bot

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}
parent 6d0b3151
...@@ -494,10 +494,10 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, BlobsCountAgainstQuota) { ...@@ -494,10 +494,10 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, BlobsCountAgainstQuota) {
} }
IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DeleteForOriginDeletesBlobs) { 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(); int64_t size = RequestDiskUsage();
// This assertion assumes that we do not compress blobs. // 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. // TODO(jsbell): Remove static_cast<> when overloads are eliminated.
GetContext()->TaskRunner()->PostTask( GetContext()->TaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// Constants. // Constants.
var store_name = 'blobs_use_space'; var store_name = 'blobs_use_space';
var blob_key = 'blob_key'; var blob_key = 'blob_key';
var blob_size = 20 * 1024 * 1024; var blob_size = 4 * 1024 * 1024;
// Shared variables. // Shared variables.
var db; var db;
......
<!DOCTYPE html> <!DOCTYPE html>
<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 Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
--> -->
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// Constants. // Constants.
var store_name = 'blobs'; var store_name = 'blobs';
var blob_key = 'blob_key'; var blob_key = 'blob_key';
var blob_size = 20 * 1024 * 1024; // 20MB var blob_size = 4 * 1024 * 1024; // 4MB
// Shared variables. // Shared variables.
var db; var db;
......
...@@ -82,12 +82,14 @@ https://cs.chromium.org/chromium/src/storage/browser/blob/blob_memory_controller ...@@ -82,12 +82,14 @@ https://cs.chromium.org/chromium/src/storage/browser/blob/blob_memory_controller
**In-Memory Storage Limit** **In-Memory Storage Limit**
* If the architecture is x64 and NOT Chrome OS or Android: `2GB` * 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** **Disk Storage Limit**
* If Chrome OS: `disk_size / 2` * If Chrome OS: `disk_size / 2`
* If Android: `disk_size / 20` * If Android: `6 * disk_size / 100`
* Else: `disk_size / 10` * Else: `disk_size / 10`
Note: Chrome OS's disk is part of the user partition, which is separate from the Note: Chrome OS's disk is part of the user partition, which is separate from the
...@@ -102,16 +104,14 @@ we use is: ...@@ -102,16 +104,14 @@ we use is:
## Example Limits ## Example Limits
(All sizes in GB)
| Device | Ram | In-Memory Limit | Disk | Disk Limit | Min Disk Availability | | Device | Ram | In-Memory Limit | Disk | Disk Limit | Min Disk Availability |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- |
| Cast | 0.5 | 0.1 | 0 | 0 | 0 | | Cast | 512 MB | 102 MB | 0 | 0 | 0 |
| Android Minimal | 0.5 | 0.1 | 8 | 0.4 | 0.2 | | Android Minimal | 512 MB | 5 MB | 8 GB | 491 MB | 10 MB |
| Android Fat | 2 | 0.4 | 32 | 1.5 | 0.8 | | Android Fat | 2 GB | 20 MB | 32 GB | 1.9 GB | 40 MB |
| CrOS | 2 | 0.4 | 8 | 4 | 0.8 | | CrOS | 2 GB | 409 MB | 8 GB | 4 GB | 0.8 GB |
| Desktop 32 | 3 | 0.6 | 500 | 50 | 1.2 | | Desktop 32 | 3 GB | 614 MB | 500 GB | 50 GB | 1.2 GB |
| Desktop 64 | 4 | 2 | 500 | 50 | 4 | | Desktop 64 | 4 GB | 2 GB | 500 GB | 50 GB | 4 GB |
# Common Pitfalls # Common Pitfalls
...@@ -128,7 +128,7 @@ the renderer can get rid of the data. ...@@ -128,7 +128,7 @@ the renderer can get rid of the data.
## Leaking Blob References ## Leaking Blob References
If the blob object in Javascript is kept around, then the data will never be 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. 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 Similarily if a URL is created for a blob, this will keep the blob data around
......
...@@ -53,8 +53,8 @@ using DiskSpaceFuncPtr = BlobMemoryController::DiskSpaceFuncPtr; ...@@ -53,8 +53,8 @@ using DiskSpaceFuncPtr = BlobMemoryController::DiskSpaceFuncPtr;
// Note: The disk is the user partition, so the operating system can still // Note: The disk is the user partition, so the operating system can still
// function if this is full. // function if this is full.
// Android: // Android:
// * RAM - 20% // * RAM - 1%
// * Disk - 5% // * Disk - 6%
// Desktop: // Desktop:
// * Ram - 20%, or 2 GB if x64. // * Ram - 20%, or 2 GB if x64.
// * Disk - 10% // * Disk - 10%
...@@ -71,6 +71,8 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir, ...@@ -71,6 +71,8 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir,
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && defined(ARCH_CPU_64_BITS) #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && defined(ARCH_CPU_64_BITS)
constexpr size_t kTwoGigabytes = 2ull * 1024 * 1024 * 1024; constexpr size_t kTwoGigabytes = 2ull * 1024 * 1024 * 1024;
limits.max_blob_in_memory_space = kTwoGigabytes; 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 #else
limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5ll); limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5ll);
#endif #endif
...@@ -81,7 +83,7 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir, ...@@ -81,7 +83,7 @@ BlobStorageLimits CalculateBlobStorageLimitsImpl(const FilePath& storage_dir,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 2ll); limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 2ll);
#elif defined(OS_ANDROID) #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 #else
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 10ll); limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 10ll);
#endif #endif
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "build/build_config.h"
#include "storage/common/storage_common_export.h" #include "storage/common/storage_common_export.h"
namespace storage { namespace storage {
...@@ -17,9 +18,15 @@ constexpr size_t kDefaultIPCMemorySize = 250u * 1024; ...@@ -17,9 +18,15 @@ constexpr size_t kDefaultIPCMemorySize = 250u * 1024;
constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024; constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024;
constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024; constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024;
constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull; constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull;
constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024;
constexpr uint64_t kDefaultMaxPageFileSize = 100ull * 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. // All sizes are in bytes.
struct STORAGE_COMMON_EXPORT BlobStorageLimits { struct STORAGE_COMMON_EXPORT BlobStorageLimits {
// Returns if the current configuration is valid. // Returns if the current configuration is valid.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment