@@ -60,6 +60,9 @@ CacheAllocator<CacheTrait>::CacheAllocator(
6060 tempShm_ (type == InitMemType::kNone && isOnShm_
6161 ? std::make_unique<TempShmMapping>(config_.getCacheSize())
6262 : nullptr ),
63+ privMemManager_ (type == InitMemType::kNone && !isOnShm_
64+ ? std::make_unique<PrivateMemoryManager>()
65+ : nullptr ),
6366 shmManager_ (type != InitMemType::kNone
6467 ? std::make_unique<ShmManager>(config_.cacheDir,
6568 config_.isUsingPosixShm())
@@ -123,6 +126,16 @@ ShmSegmentOpts CacheAllocator<CacheTrait>::createShmCacheOpts(TierId tid) {
123126 return opts;
124127}
125128
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+
126139template <typename CacheTrait>
127140size_t CacheAllocator<CacheTrait>::memoryTierSize(TierId tid) const {
128141 auto partitions = std::accumulate (memoryTierConfigs.begin (), memoryTierConfigs.end (), 0UL ,
@@ -134,21 +147,18 @@ size_t CacheAllocator<CacheTrait>::memoryTierSize(TierId tid) const {
134147}
135148
136149template <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) {
141152 if (isOnShm_)
142- allocators. emplace_back ( std::make_unique<MemoryAllocator>(
153+ return std::make_unique<MemoryAllocator>(
143154 getAllocatorConfig (config_),
144155 tempShm_->getAddr (),
145- config_. getCacheSize () ));
156+ memoryTierSize (tid ));
146157 else
147- allocators. emplace_back ( std::make_unique<MemoryAllocator>(
158+ return std::make_unique<MemoryAllocator>(
148159 getAllocatorConfig (config_),
149- config_.getCacheSize ()));
150-
151- return allocators;
160+ privMemManager_->createMapping (config_.size , createPrivateSegmentOpts (tid)),
161+ memoryTierSize (tid));
152162}
153163
154164template <typename CacheTrait>
@@ -177,6 +187,16 @@ CacheAllocator<CacheTrait>::restoreMemoryAllocator(TierId tid) {
177187 config_.disableFullCoredump );
178188}
179189
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+
180200template <typename CacheTrait>
181201std::vector<std::unique_ptr<MemoryAllocator>>
182202CacheAllocator<CacheTrait>::createAllocators() {
@@ -310,7 +330,7 @@ std::vector<std::unique_ptr<MemoryAllocator>>
310330CacheAllocator<CacheTrait>::initAllocator(
311331 InitMemType type) {
312332 if (type == InitMemType::kNone ) {
313- return createPrivateAllocator ();
333+ return createPrivateAllocators ();
314334 } else if (type == InitMemType::kMemNew ) {
315335 return createAllocators ();
316336 } else if (type == InitMemType::kMemAttach ) {
0 commit comments