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