@@ -1308,7 +1308,7 @@ class CacheAllocator : public CacheBase {
1308
1308
1309
1309
private:
1310
1310
// wrapper around Item's refcount and active handle tracking
1311
- FOLLY_ALWAYS_INLINE void incRef (Item& it);
1311
+ FOLLY_ALWAYS_INLINE bool incRef (Item& it);
1312
1312
FOLLY_ALWAYS_INLINE RefcountWithFlags::Value decRef (Item& it);
1313
1313
1314
1314
// drops the refcount and if needed, frees the allocation back to the memory
@@ -1359,6 +1359,12 @@ class CacheAllocator : public CacheBase {
1359
1359
bool nascent = false ,
1360
1360
const Item* toRecycle = nullptr );
1361
1361
1362
+ // Must be called by the thread which called markForEviction and
1363
+ // succeeded. After this call, the item is unlinked from Access and
1364
+ // MM Containers. The item is no longer marked as exclusive and it's
1365
+ // ref count is 0 - it's available for recycling.
1366
+ void unlinkItemForEviction (Item& it);
1367
+
1362
1368
// acquires an handle on the item. returns an empty handle if it is null.
1363
1369
// @param it pointer to an item
1364
1370
// @return WriteHandle return a handle to this item
@@ -1448,17 +1454,17 @@ class CacheAllocator : public CacheBase {
1448
1454
// @return handle to the parent item if the validations pass
1449
1455
// otherwise, an empty Handle is returned.
1450
1456
//
1451
- ReadHandle validateAndGetParentHandleForChainedMoveLocked (
1457
+ WriteHandle validateAndGetParentHandleForChainedMoveLocked (
1452
1458
const ChainedItem& item, const Key& parentKey);
1453
1459
1454
1460
// Given an existing item, allocate a new one for the
1455
1461
// existing one to later be moved into.
1456
1462
//
1457
- // @param oldItem the item we want to allocate a new item for
1463
+ // @param item reference to the item we want to allocate a new item for
1458
1464
//
1459
1465
// @return handle to the newly allocated item
1460
1466
//
1461
- WriteHandle allocateNewItemForOldItem (const Item& oldItem );
1467
+ WriteHandle allocateNewItemForOldItem (const Item& item );
1462
1468
1463
1469
// internal helper that grabs a refcounted handle to the item. This does
1464
1470
// not record the access to reflect in the mmContainer.
@@ -1512,7 +1518,7 @@ class CacheAllocator : public CacheBase {
1512
1518
// callback is responsible for copying the contents and fixing the semantics
1513
1519
// of chained item.
1514
1520
//
1515
- // @param oldItem Reference to the item being moved
1521
+ // @param oldItem item being moved
1516
1522
// @param newItemHdl Reference to the handle of the new item being moved into
1517
1523
//
1518
1524
// @return true If the move was completed, and the containers were updated
@@ -1662,25 +1668,6 @@ class CacheAllocator : public CacheBase {
1662
1668
1663
1669
using EvictionIterator = typename MMContainer::Iterator;
1664
1670
1665
- // Advance the current iterator and try to evict a regular item
1666
- //
1667
- // @param mmContainer the container to look for evictions.
1668
- // @param itr iterator holding the item
1669
- //
1670
- // @return valid handle to regular item on success. This will be the last
1671
- // handle to the item. On failure an empty handle.
1672
- WriteHandle advanceIteratorAndTryEvictRegularItem (MMContainer& mmContainer,
1673
- EvictionIterator& itr);
1674
-
1675
- // Advance the current iterator and try to evict a chained item
1676
- // Iterator may also be reset during the course of this function
1677
- //
1678
- // @param itr iterator holding the item
1679
- //
1680
- // @return valid handle to the parent item on success. This will be the last
1681
- // handle to the item
1682
- WriteHandle advanceIteratorAndTryEvictChainedItem (EvictionIterator& itr);
1683
-
1684
1671
// Deserializer CacheAllocatorMetadata and verify the version
1685
1672
//
1686
1673
// @param deserializer Deserializer object
@@ -1756,22 +1743,23 @@ class CacheAllocator : public CacheBase {
1756
1743
1757
1744
// @return true when successfully marked as moving,
1758
1745
// fasle when this item has already been freed
1759
- bool markExclusiveForSlabRelease (const SlabReleaseContext& ctx,
1760
- void * alloc,
1761
- util::Throttler& throttler);
1746
+ bool markMovingForSlabRelease (const SlabReleaseContext& ctx,
1747
+ void * alloc,
1748
+ util::Throttler& throttler);
1762
1749
1763
1750
// "Move" (by copying) the content in this item to another memory
1764
1751
// location by invoking the move callback.
1765
1752
//
1766
1753
//
1767
1754
// @param ctx slab release context
1768
- // @param item old item to be moved elsewhere
1755
+ // @param oldItem old item to be moved elsewhere
1756
+ // @param handle handle to the item or to it's parent (if chained)
1769
1757
// @param throttler slow this function down as not to take too much cpu
1770
1758
//
1771
1759
// @return true if the item has been moved
1772
1760
// false if we have exhausted moving attempts
1773
1761
bool moveForSlabRelease (const SlabReleaseContext& ctx,
1774
- Item& item ,
1762
+ Item& oldItem ,
1775
1763
util::Throttler& throttler);
1776
1764
1777
1765
// "Move" (by copying) the content in this item to another memory
@@ -1794,18 +1782,7 @@ class CacheAllocator : public CacheBase {
1794
1782
Item& item,
1795
1783
util::Throttler& throttler);
1796
1784
1797
- // Helper function to evict a normal item for slab release
1798
- //
1799
- // @return last handle for corresponding to item on success. empty handle on
1800
- // failure. caller can retry if needed.
1801
- WriteHandle evictNormalItemForSlabRelease (Item& item);
1802
-
1803
- // Helper function to evict a child item for slab release
1804
- // As a side effect, the parent item is also evicted
1805
- //
1806
- // @return last handle to the parent item of the child on success. empty
1807
- // handle on failure. caller can retry.
1808
- WriteHandle evictChainedItemForSlabRelease (ChainedItem& item);
1785
+ typename NvmCacheT::PutToken createPutToken (Item& item);
1809
1786
1810
1787
// Helper function to remove a item if expired.
1811
1788
//
@@ -1927,18 +1904,14 @@ class CacheAllocator : public CacheBase {
1927
1904
std::optional<bool > saveNvmCache ();
1928
1905
void saveRamCache ();
1929
1906
1930
- static bool itemExclusivePredicate (const Item& item) {
1931
- return item.getRefCount () == 0 ;
1907
+ static bool itemSlabMovePredicate (const Item& item) {
1908
+ return item.isMoving () && item. getRefCount () == 0 ;
1932
1909
}
1933
1910
1934
1911
static bool itemExpiryPredicate (const Item& item) {
1935
1912
return item.getRefCount () == 1 && item.isExpired ();
1936
1913
}
1937
1914
1938
- static bool parentEvictForSlabReleasePredicate (const Item& item) {
1939
- return item.getRefCount () == 1 && !item.isExclusive ();
1940
- }
1941
-
1942
1915
std::unique_ptr<Deserializer> createDeserializer ();
1943
1916
1944
1917
// Execute func on each item. `func` can throw exception but must ensure
0 commit comments