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

Side by Side Diff: base/metrics/persistent_memory_allocator.h

Issue 1840843004: Improve efficiency of persistent sparse histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@improved-pma-iterator
Patch Set: added comment clarifying loop behavior Created 4 years, 8 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ 5 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ 6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <atomic> 10 #include <atomic>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 DISALLOW_COPY_AND_ASSIGN(Iterator); 112 DISALLOW_COPY_AND_ASSIGN(Iterator);
113 }; 113 };
114 114
115 // Returned information about the internal state of the heap. 115 // Returned information about the internal state of the heap.
116 struct MemoryInfo { 116 struct MemoryInfo {
117 size_t total; 117 size_t total;
118 size_t free; 118 size_t free;
119 }; 119 };
120 120
121 enum : Reference {
122 kReferenceNull = 0 // A common "null" reference value.
123 };
124
121 enum : uint32_t { 125 enum : uint32_t {
122 kTypeIdAny = 0 // Match any type-id inside GetAsObject(). 126 kTypeIdAny = 0 // Match any type-id inside GetAsObject().
123 }; 127 };
124 128
125 // The allocator operates on any arbitrary block of memory. Creation and 129 // The allocator operates on any arbitrary block of memory. Creation and
126 // persisting or sharing of that block with another process is the 130 // persisting or sharing of that block with another process is the
127 // responsibility of the caller. The allocator needs to know only the 131 // responsibility of the caller. The allocator needs to know only the
128 // block's |base| address, the total |size| of the block, and any internal 132 // block's |base| address, the total |size| of the block, and any internal
129 // |page| size (zero if not paged) across which allocations should not span. 133 // |page| size (zero if not paged) across which allocations should not span.
130 // The |id| is an arbitrary value the caller can use to identify a 134 // The |id| is an arbitrary value the caller can use to identify a
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 protected: 281 protected:
278 volatile char* const mem_base_; // Memory base. (char so sizeof guaranteed 1) 282 volatile char* const mem_base_; // Memory base. (char so sizeof guaranteed 1)
279 const uint32_t mem_size_; // Size of entire memory segment. 283 const uint32_t mem_size_; // Size of entire memory segment.
280 const uint32_t mem_page_; // Page size allocations shouldn't cross. 284 const uint32_t mem_page_; // Page size allocations shouldn't cross.
281 285
282 private: 286 private:
283 struct SharedMetadata; 287 struct SharedMetadata;
284 struct BlockHeader; 288 struct BlockHeader;
285 static const uint32_t kAllocAlignment; 289 static const uint32_t kAllocAlignment;
286 static const Reference kReferenceQueue; 290 static const Reference kReferenceQueue;
287 static const Reference kReferenceNull;
288 291
289 // The shared metadata is always located at the top of the memory segment. 292 // The shared metadata is always located at the top of the memory segment.
290 // These convenience functions eliminate constant casting of the base 293 // These convenience functions eliminate constant casting of the base
291 // pointer within the code. 294 // pointer within the code.
292 const SharedMetadata* shared_meta() const { 295 const SharedMetadata* shared_meta() const {
293 return reinterpret_cast<const SharedMetadata*>( 296 return reinterpret_cast<const SharedMetadata*>(
294 const_cast<const char*>(mem_base_)); 297 const_cast<const char*>(mem_base_));
295 } 298 }
296 SharedMetadata* shared_meta() { 299 SharedMetadata* shared_meta() {
297 return reinterpret_cast<SharedMetadata*>(const_cast<char*>(mem_base_)); 300 return reinterpret_cast<SharedMetadata*>(const_cast<char*>(mem_base_));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 398
396 private: 399 private:
397 std::unique_ptr<MemoryMappedFile> mapped_file_; 400 std::unique_ptr<MemoryMappedFile> mapped_file_;
398 401
399 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); 402 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator);
400 }; 403 };
401 404
402 } // namespace base 405 } // namespace base
403 406
404 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ 407 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | base/metrics/persistent_memory_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698