@@ -60,6 +60,9 @@ CacheAllocator<CacheTrait>::CacheAllocator(
60
60
tempShm_ (type == InitMemType::kNone && isOnShm_
61
61
? std::make_unique<TempShmMapping>(config_.getCacheSize())
62
62
: nullptr ),
63
+ privMemManager_ (type == InitMemType::kNone && !isOnShm_
64
+ ? std::make_unique<PrivateMemoryManager>()
65
+ : nullptr ),
63
66
shmManager_ (type != InitMemType::kNone
64
67
? std::make_unique<ShmManager>(config_.cacheDir,
65
68
config_.isUsingPosixShm())
@@ -123,6 +126,16 @@ ShmSegmentOpts CacheAllocator<CacheTrait>::createShmCacheOpts(TierId tid) {
123
126
return opts;
124
127
}
125
128
129
+ template <typename CacheTrait>
130
+ PrivateSegmentOpts CacheAllocator<CacheTrait>::createPrivateSegmentOpts(TierId tid) {
131
+ PrivateSegmentOpts opts;
132
+ opts.alignment = sizeof (Slab);
133
+ auto memoryTierConfigs = config_.getMemoryTierConfigs ();
134
+ opts.memBindNumaNodes = memoryTierConfigs[tid].getMemBind ();
135
+
136
+ return opts;
137
+ }
138
+
126
139
template <typename CacheTrait>
127
140
size_t CacheAllocator<CacheTrait>::memoryTierSize(TierId tid) const {
128
141
auto partitions = std::accumulate (memoryTierConfigs.begin (), memoryTierConfigs.end (), 0UL ,
@@ -134,21 +147,18 @@ size_t CacheAllocator<CacheTrait>::memoryTierSize(TierId tid) const {
134
147
}
135
148
136
149
template <typename CacheTrait>
137
- std::vector<std::unique_ptr<MemoryAllocator>>
138
- CacheAllocator<CacheTrait>::createPrivateAllocator() {
139
- std::vector<std::unique_ptr<MemoryAllocator>> allocators;
140
-
150
+ std::unique_ptr<MemoryAllocator>
151
+ CacheAllocator<CacheTrait>::createPrivateAllocator(TierId tid) {
141
152
if (isOnShm_)
142
- allocators. emplace_back ( std::make_unique<MemoryAllocator>(
153
+ return std::make_unique<MemoryAllocator>(
143
154
getAllocatorConfig (config_),
144
155
tempShm_->getAddr (),
145
- config_. getCacheSize () ));
156
+ memoryTierSize (tid ));
146
157
else
147
- allocators. emplace_back ( std::make_unique<MemoryAllocator>(
158
+ return std::make_unique<MemoryAllocator>(
148
159
getAllocatorConfig (config_),
149
- config_.getCacheSize ()));
150
-
151
- return allocators;
160
+ privMemManager_->createMapping (config_.size , createPrivateSegmentOpts (tid)),
161
+ memoryTierSize (tid));
152
162
}
153
163
154
164
template <typename CacheTrait>
@@ -177,6 +187,16 @@ CacheAllocator<CacheTrait>::restoreMemoryAllocator(TierId tid) {
177
187
config_.disableFullCoredump );
178
188
}
179
189
190
+ template <typename CacheTrait>
191
+ std::vector<std::unique_ptr<MemoryAllocator>>
192
+ CacheAllocator<CacheTrait>::createPrivateAllocators() {
193
+ std::vector<std::unique_ptr<MemoryAllocator>> allocators;
194
+ for (int tid = 0 ; tid < getNumTiers (); tid++) {
195
+ allocators.emplace_back (createPrivateAllocator (tid));
196
+ }
197
+ return allocators;
198
+ }
199
+
180
200
template <typename CacheTrait>
181
201
std::vector<std::unique_ptr<MemoryAllocator>>
182
202
CacheAllocator<CacheTrait>::createAllocators() {
@@ -310,7 +330,7 @@ std::vector<std::unique_ptr<MemoryAllocator>>
310
330
CacheAllocator<CacheTrait>::initAllocator(
311
331
InitMemType type) {
312
332
if (type == InitMemType::kNone ) {
313
- return createPrivateAllocator ();
333
+ return createPrivateAllocators ();
314
334
} else if (type == InitMemType::kMemNew ) {
315
335
return createAllocators ();
316
336
} else if (type == InitMemType::kMemAttach ) {
0 commit comments