@@ -59,6 +59,9 @@ CacheAllocator<CacheTrait>::CacheAllocator(
5959      tempShm_ (type == InitMemType::kNone  && isOnShm_
6060                   ? std::make_unique<TempShmMapping>(config_.getCacheSize())
6161                   : nullptr ),
62+       privMemManager_ (type == InitMemType::kNone  && !isOnShm_
63+                           ? std::make_unique<PrivateMemoryManager>()
64+                           : nullptr ),
6265      shmManager_ (type != InitMemType::kNone 
6366                      ? std::make_unique<ShmManager>(config_.cacheDir,
6467                                                     config_.isUsingPosixShm())
@@ -121,6 +124,16 @@ ShmSegmentOpts CacheAllocator<CacheTrait>::createShmCacheOpts(TierId tid) {
121124  return  opts;
122125}
123126
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+ 
124137template  <typename  CacheTrait>
125138size_t  CacheAllocator<CacheTrait>::memoryTierSize(TierId tid) const  {
126139  auto & memoryTierConfigs = config_.memoryTierConfigs ;
@@ -133,21 +146,18 @@ size_t CacheAllocator<CacheTrait>::memoryTierSize(TierId tid) const {
133146}
134147
135148template  <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) {
140151  if  (isOnShm_)
141-     allocators. emplace_back ( std::make_unique<MemoryAllocator>(
152+     return   std::make_unique<MemoryAllocator>(
142153                            getAllocatorConfig (config_),
143154                            tempShm_->getAddr (),
144-                             config_. getCacheSize () ));
155+                             memoryTierSize (tid ));
145156  else 
146-     allocators. emplace_back ( std::make_unique<MemoryAllocator>(
157+     return   std::make_unique<MemoryAllocator>(
147158                            getAllocatorConfig (config_),
148-                             config_.getCacheSize ()));
149- 
150-   return  allocators;
159+                             privMemManager_->createMapping (config_.size , createPrivateSegmentOpts (tid)),
160+                             memoryTierSize (tid));
151161}
152162
153163template  <typename  CacheTrait>
@@ -176,6 +186,16 @@ CacheAllocator<CacheTrait>::restoreMemoryAllocator(TierId tid) {
176186      config_.disableFullCoredump );
177187}
178188
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+ 
179199template  <typename  CacheTrait>
180200std::vector<std::unique_ptr<MemoryAllocator>>
181201CacheAllocator<CacheTrait>::createAllocators() {
@@ -309,7 +329,7 @@ std::vector<std::unique_ptr<MemoryAllocator>>
309329CacheAllocator<CacheTrait>::initAllocator(
310330    InitMemType type) {
311331  if  (type == InitMemType::kNone ) {
312-     return  createPrivateAllocator ();
332+     return  createPrivateAllocators ();
313333  } else  if  (type == InitMemType::kMemNew ) {
314334    return  createAllocators ();
315335  } else  if  (type == InitMemType::kMemAttach ) {
0 commit comments