Skip to content

Commit 862f069

Browse files
Merge pull request #1 from haochengxia/s4fifo
Init S4-FIFO
2 parents 3a2af32 + 62bf14d commit 862f069

File tree

7 files changed

+1283
-0
lines changed

7 files changed

+1283
-0
lines changed

cachelib/allocator/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ add_library (cachelib_allocator
3535
CacheAllocatorLruCacheWithSpinBuckets.cpp
3636
CacheAllocatorS3FIFOCache.cpp
3737
CacheAllocatorS3FIFO5BCache.cpp
38+
CacheAllocatorS4FIFOCache.cpp
39+
CacheAllocatorS4FIFO5BCache.cpp
3840
CacheAllocatorTinyLFU5BCache.cpp
3941
CacheAllocatorTinyLFUCache.cpp
4042
CacheAllocatorWTinyLFU5BCache.cpp
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "cachelib/allocator/CacheAllocator.h"
18+
19+
namespace facebook::cachelib {
20+
template class CacheAllocator<S4FIFO5BCacheTrait>;
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "cachelib/allocator/CacheAllocator.h"
18+
19+
namespace facebook::cachelib {
20+
template class CacheAllocator<S4FIFOCacheTrait>;
21+
}

cachelib/allocator/CacheTraits.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "cachelib/allocator/MM2Q.h"
2020
#include "cachelib/allocator/MMLru.h"
2121
#include "cachelib/allocator/MMS3FIFO.h"
22+
#include "cachelib/allocator/MMS4FIFO.h"
2223
#include "cachelib/allocator/MMTinyLFU.h"
2324
#include "cachelib/allocator/MMWTinyLFU.h"
2425
#include "cachelib/allocator/memory/CompressedPtr.h"
@@ -62,6 +63,13 @@ struct S3FIFOCacheTrait {
6263
using CompressedPtrType = CompressedPtr4B;
6364
};
6465

66+
struct S4FIFOCacheTrait {
67+
using MMType = MMS4FIFO;
68+
using AccessType = ChainedHashTable;
69+
using AccessTypeLocks = SharedMutexBuckets;
70+
using CompressedPtrType = CompressedPtr4B;
71+
};
72+
6573
struct TinyLFUCacheTrait {
6674
using MMType = MMTinyLFU;
6775
using AccessType = ChainedHashTable;
@@ -104,6 +112,13 @@ struct S3FIFO5BCacheTrait {
104112
using CompressedPtrType = CompressedPtr5B;
105113
};
106114

115+
struct S4FIFO5BCacheTrait {
116+
using MMType = MMS4FIFO;
117+
using AccessType = ChainedHashTable;
118+
using AccessTypeLocks = SharedMutexBuckets;
119+
using CompressedPtrType = CompressedPtr5B;
120+
};
121+
107122
struct TinyLFU5BCacheTrait {
108123
using MMType = MMTinyLFU;
109124
using AccessType = ChainedHashTable;

cachelib/allocator/ContainerTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "cachelib/allocator/MM2Q.h"
1919
#include "cachelib/allocator/MMLru.h"
2020
#include "cachelib/allocator/MMS3FIFO.h"
21+
#include "cachelib/allocator/MMS4FIFO.h"
2122
#include "cachelib/allocator/MMTinyLFU.h"
2223
#include "cachelib/allocator/MMWTinyLFU.h"
2324
namespace facebook::cachelib {
@@ -28,6 +29,7 @@ const int MM2Q::kId = 2;
2829
const int MMTinyLFU::kId = 3;
2930
const int MMWTinyLFU::kId = 4;
3031
const int MMS3FIFO::kId = 5;
32+
const int MMS4FIFO::kId = 6;
3133

3234
// AccessType
3335
const int ChainedHashTable::kId = 1;

0 commit comments

Comments
 (0)