Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: storage/common/blob_storage/blob_storage_constants.h

Issue 2857283002: Add memory pressure listener to Blob storage (Closed)
Patch Set: Rename constant, use base::Uma function and add base attribute. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ 5 #ifndef STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_
6 #define STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ 6 #define STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "storage/common/storage_common_export.h" 13 #include "storage/common/storage_common_export.h"
14 14
15 namespace storage { 15 namespace storage {
16 16
17 constexpr size_t kDefaultIPCMemorySize = 250u * 1024; 17 constexpr size_t kDefaultIPCMemorySize = 250u * 1024;
18 constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024; 18 constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024;
19 constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024; 19 constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024;
20 constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull; 20 constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull;
21 constexpr uint64_t kDefaultMaxPageFileSize = 100ull * 1024 * 1024; 21 constexpr uint64_t kDefaultMaxPageFileSize = 100ull * 1024 * 1024;
22 22
23 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
24 // On minimal Android maximum in-memory space can be as low as 5MB. 24 // On minimal Android maximum in-memory space can be as low as 5MB.
25 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024 / 2; 25 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024 / 2;
26 const float kDefaultMaxBlobInMemorySpaceUnderPressureRatio = 0.02f;
26 #else 27 #else
27 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024; 28 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024;
29 const float kDefaultMaxBlobInMemorySpaceUnderPressureRatio = 0.002f;
28 #endif 30 #endif
29 31
30 // All sizes are in bytes. 32 // All sizes are in bytes.
31 struct STORAGE_COMMON_EXPORT BlobStorageLimits { 33 struct STORAGE_COMMON_EXPORT BlobStorageLimits {
32 // Returns if the current configuration is valid. 34 // Returns if the current configuration is valid.
33 bool IsValid() const; 35 bool IsValid() const;
34 36
35 size_t memory_limit_before_paging() const { 37 size_t memory_limit_before_paging() const {
36 return max_blob_in_memory_space - min_page_file_size; 38 return max_blob_in_memory_space - min_page_file_size;
37 } 39 }
38 40
39 // If disk space goes less than this we stop allocating more disk quota. 41 // If disk space goes less than this we stop allocating more disk quota.
40 uint64_t min_available_external_disk_space() const { 42 uint64_t min_available_external_disk_space() const {
41 return 2ull * memory_limit_before_paging(); 43 return 2ull * memory_limit_before_paging();
42 } 44 }
43 45
44 bool IsDiskSpaceConstrained() const { 46 bool IsDiskSpaceConstrained() const {
45 return desired_max_disk_space != effective_max_disk_space; 47 return desired_max_disk_space != effective_max_disk_space;
46 } 48 }
47 49
48 // This is the maximum amount of memory we can send in an IPC. 50 // This is the maximum amount of memory we can send in an IPC.
49 size_t max_ipc_memory_size = kDefaultIPCMemorySize; 51 size_t max_ipc_memory_size = kDefaultIPCMemorySize;
50 // This is the maximum size of a shared memory handle. 52 // This is the maximum size of a shared memory handle.
51 size_t max_shared_memory_size = kDefaultSharedMemorySize; 53 size_t max_shared_memory_size = kDefaultSharedMemorySize;
52 54
53 // This is the maximum amount of memory we can use to store blobs. 55 // This is the maximum amount of memory we can use to store blobs.
54 size_t max_blob_in_memory_space = kDefaultMaxBlobInMemorySpace; 56 size_t max_blob_in_memory_space = kDefaultMaxBlobInMemorySpace;
57 // The ratio applied to |max_blob_in_memory_space| to reduce memory usage
58 // under memory pressure. Note: Under pressure we modify the
59 // |min_page_file_size| to ensure we can evict items until we get below the
60 // reduced memory limit.
61 float max_blob_in_memory_space_under_pressure_ratio =
62 kDefaultMaxBlobInMemorySpaceUnderPressureRatio;
55 63
56 // This is the maximum amount of disk space we can use. 64 // This is the maximum amount of disk space we can use.
57 uint64_t desired_max_disk_space = kDefaultMaxBlobDiskSpace; 65 uint64_t desired_max_disk_space = kDefaultMaxBlobDiskSpace;
58 // This value will change based on the amount of free space on the device. 66 // This value will change based on the amount of free space on the device.
59 uint64_t effective_max_disk_space = kDefaultMaxBlobDiskSpace; 67 uint64_t effective_max_disk_space = kDefaultMaxBlobDiskSpace;
60 68
61 // This is the minimum file size we can use when paging blob items to disk. 69 // This is the minimum file size we can use when paging blob items to disk.
62 // We combine items until we reach at least this size. 70 // We combine items until we reach at least this size.
63 uint64_t min_page_file_size = kDefaultMinPageFileSize; 71 uint64_t min_page_file_size = kDefaultMinPageFileSize;
64 // This is the maximum file size we can create. 72 // This is the maximum file size we can create.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 126
119 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status); 127 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status);
120 128
121 // Returns if the status is a bad enough error to flag the IPC as bad. This is 129 // Returns if the status is a bad enough error to flag the IPC as bad. This is
122 // only INVALID_CONSTRUCTION_ARGUMENTS. 130 // only INVALID_CONSTRUCTION_ARGUMENTS.
123 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); 131 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status);
124 132
125 } // namespace storage 133 } // namespace storage
126 134
127 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ 135 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_
OLDNEW
« no previous file with comments | « storage/browser/blob/blob_memory_controller_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698