@@ -94,28 +94,30 @@ class AllocatorMemoryTiersTest : public AllocatorTest<AllocatorT> {
94
94
const auto key = this ->getRandomNewKey (*allocator, keyLen);
95
95
auto handle = util::allocateAccessible (*allocator, poolId, key, sizes[0 ]);
96
96
ASSERT_NE (nullptr , handle);
97
+
97
98
const uint8_t cid = allocator->getAllocInfo (handle->getMemory ()).classId ;
98
-
99
-
100
99
auto stats = allocator->getGlobalCacheStats ();
101
- while (stats.evictionStats .runCount < 1 ) {
100
+ auto slabStats = allocator->getAllocationClassStats (0 ,0 ,cid);
101
+ const auto & mpStats = allocator->getPoolByTid (poolId, 0 ).getStats ();
102
+ // cache is 10MB should move about 1MB to reach 10% free
103
+ uint32_t approxEvict = (1024 *1024 )/mpStats.acStats .at (cid).allocSize ;
104
+ while (stats.evictionStats .numMovedItems < approxEvict*0.95 && slabStats.approxFreePercent >= 9.5 ) {
102
105
std::this_thread::sleep_for (std::chrono::seconds (1 ));
103
106
stats = allocator->getGlobalCacheStats ();
107
+ slabStats = allocator->getAllocationClassStats (0 ,0 ,cid);
104
108
}
109
+ ASSERT_GE (slabStats.approxFreePercent ,9.5 );
105
110
106
111
auto perclassEstats = allocator->getBackgroundMoverClassStats (MoverDir::Evict);
107
112
auto perclassPstats = allocator->getBackgroundMoverClassStats (MoverDir::Promote);
108
113
109
- EXPECT_GT (stats.evictionStats .numMovedItems ,1 );
110
- EXPECT_GT (stats.evictionStats .runCount ,1 );
111
- EXPECT_GT (stats.promotionStats .numMovedItems ,1 );
114
+ ASSERT_GE (stats.evictionStats .numMovedItems ,1 );
115
+ ASSERT_GE (stats.evictionStats .runCount ,1 );
116
+ ASSERT_GE (stats.promotionStats .numMovedItems ,1 );
112
117
113
- EXPECT_GT (perclassEstats[0 ][0 ][cid], 1 );
114
- EXPECT_GT (perclassPstats[1 ][0 ][cid], 1 );
118
+ ASSERT_GE (perclassEstats[0 ][0 ][cid], 1 );
119
+ ASSERT_GE (perclassPstats[1 ][0 ][cid], 1 );
115
120
116
- auto slabStats = allocator->getAllocationClassStats (0 ,0 ,cid);
117
-
118
- ASSERT_GE (slabStats.approxFreePercent ,10 );
119
121
}
120
122
121
123
void testMultiTiersValidMixed () {
0 commit comments