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

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

Issue 2857283002: Add memory pressure listener to Blob storage (Closed)
Patch Set: ratio and pressue arg. 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 kDefaultMinPageFileSizeRatioUnderPressure = 0.02;
26 #else 27 #else
27 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024; 28 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024;
29 const float kDefaultMinPageFileSizeRatioUnderPressure = 0.002;
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 }
(...skipping 16 matching lines...) Expand all
54 size_t max_blob_in_memory_space = kDefaultMaxBlobInMemorySpace; 56 size_t max_blob_in_memory_space = kDefaultMaxBlobInMemorySpace;
55 57
56 // This is the maximum amount of disk space we can use. 58 // This is the maximum amount of disk space we can use.
57 uint64_t desired_max_disk_space = kDefaultMaxBlobDiskSpace; 59 uint64_t desired_max_disk_space = kDefaultMaxBlobDiskSpace;
58 // This value will change based on the amount of free space on the device. 60 // This value will change based on the amount of free space on the device.
59 uint64_t effective_max_disk_space = kDefaultMaxBlobDiskSpace; 61 uint64_t effective_max_disk_space = kDefaultMaxBlobDiskSpace;
60 62
61 // This is the minimum file size we can use when paging blob items to disk. 63 // 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. 64 // We combine items until we reach at least this size.
63 uint64_t min_page_file_size = kDefaultMinPageFileSize; 65 uint64_t min_page_file_size = kDefaultMinPageFileSize;
66 // Ratio of minimum page file size to use to the |max_blob_in_memory_space|,
67 // when under memory pressure (to avoid causing peaks due to file write
68 // buffers).
69 float min_page_file_size_ratio_under_pressure =
dmurph 2017/05/10 19:13:34 Can we put this in terms of the memory limit inste
ssid 2017/05/12 01:38:01 Done.
70 kDefaultMinPageFileSizeRatioUnderPressure;
64 // This is the maximum file size we can create. 71 // This is the maximum file size we can create.
65 uint64_t max_file_size = kDefaultMaxPageFileSize; 72 uint64_t max_file_size = kDefaultMaxPageFileSize;
66 }; 73 };
67 74
68 enum class IPCBlobItemRequestStrategy { 75 enum class IPCBlobItemRequestStrategy {
69 UNKNOWN = 0, 76 UNKNOWN = 0,
70 IPC, 77 IPC,
71 SHARED_MEMORY, 78 SHARED_MEMORY,
72 FILE, 79 FILE,
73 LAST = FILE 80 LAST = FILE
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 125
119 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status); 126 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status);
120 127
121 // Returns if the status is a bad enough error to flag the IPC as bad. This is 128 // Returns if the status is a bad enough error to flag the IPC as bad. This is
122 // only INVALID_CONSTRUCTION_ARGUMENTS. 129 // only INVALID_CONSTRUCTION_ARGUMENTS.
123 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); 130 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status);
124 131
125 } // namespace storage 132 } // namespace storage
126 133
127 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ 134 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698