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

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

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
« no previous file with comments | « base/metrics/persistent_memory_allocator.h ('k') | base/metrics/persistent_sample_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/metrics/persistent_memory_allocator.h" 5 #include "base/metrics/persistent_memory_allocator.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/files/memory_mapped_file.h" 10 #include "base/files/memory_mapped_file.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 volatile std::atomic<uint32_t> tailptr; // Last block of iteration queue. 109 volatile std::atomic<uint32_t> tailptr; // Last block of iteration queue.
110 volatile BlockHeader queue; // Empty block for linked-list head/tail. 110 volatile BlockHeader queue; // Empty block for linked-list head/tail.
111 }; 111 };
112 112
113 // The "queue" block header is used to detect "last node" so that zero/null 113 // The "queue" block header is used to detect "last node" so that zero/null
114 // can be used to indicate that it hasn't been added at all. It is part of 114 // can be used to indicate that it hasn't been added at all. It is part of
115 // the SharedMetadata structure which itself is always located at offset zero. 115 // the SharedMetadata structure which itself is always located at offset zero.
116 const PersistentMemoryAllocator::Reference 116 const PersistentMemoryAllocator::Reference
117 PersistentMemoryAllocator::kReferenceQueue = 117 PersistentMemoryAllocator::kReferenceQueue =
118 offsetof(SharedMetadata, queue); 118 offsetof(SharedMetadata, queue);
119 const PersistentMemoryAllocator::Reference
120 PersistentMemoryAllocator::kReferenceNull = 0;
121 119
122 PersistentMemoryAllocator::Iterator::Iterator( 120 PersistentMemoryAllocator::Iterator::Iterator(
123 const PersistentMemoryAllocator* allocator) 121 const PersistentMemoryAllocator* allocator)
124 : allocator_(allocator), last_record_(kReferenceQueue), record_count_(0) {} 122 : allocator_(allocator), last_record_(kReferenceQueue), record_count_(0) {}
125 123
126 PersistentMemoryAllocator::Iterator::Iterator( 124 PersistentMemoryAllocator::Iterator::Iterator(
127 const PersistentMemoryAllocator* allocator, 125 const PersistentMemoryAllocator* allocator,
128 Reference starting_after) 126 Reference starting_after)
129 : allocator_(allocator), last_record_(starting_after), record_count_(0) { 127 : allocator_(allocator), last_record_(starting_after), record_count_(0) {
130 // Ensure that the starting point is a valid, iterable block (meaning it can 128 // Ensure that the starting point is a valid, iterable block (meaning it can
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 759
762 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {} 760 FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {}
763 761
764 // static 762 // static
765 bool FilePersistentMemoryAllocator::IsFileAcceptable( 763 bool FilePersistentMemoryAllocator::IsFileAcceptable(
766 const MemoryMappedFile& file) { 764 const MemoryMappedFile& file) {
767 return IsMemoryAcceptable(file.data(), file.length(), 0, true); 765 return IsMemoryAcceptable(file.data(), file.length(), 0, true);
768 } 766 }
769 767
770 } // namespace base 768 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/persistent_memory_allocator.h ('k') | base/metrics/persistent_sample_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698