@@ -94,28 +94,30 @@ class AllocatorMemoryTiersTest : public AllocatorTest<AllocatorT> {
9494 const auto key = this ->getRandomNewKey (*allocator, keyLen);
9595 auto handle = util::allocateAccessible (*allocator, poolId, key, sizes[0 ]);
9696 ASSERT_NE (nullptr , handle);
97+
9798 const uint8_t cid = allocator->getAllocInfo (handle->getMemory ()).classId ;
98-
99-
10099 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 ) {
102105 std::this_thread::sleep_for (std::chrono::seconds (1 ));
103106 stats = allocator->getGlobalCacheStats ();
107+ slabStats = allocator->getAllocationClassStats (0 ,0 ,cid);
104108 }
109+ ASSERT_GE (slabStats.approxFreePercent ,9.5 );
105110
106111 auto perclassEstats = allocator->getBackgroundMoverClassStats (MoverDir::Evict);
107112 auto perclassPstats = allocator->getBackgroundMoverClassStats (MoverDir::Promote);
108113
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 );
112117
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 );
115120
116- auto slabStats = allocator->getAllocationClassStats (0 ,0 ,cid);
117-
118- ASSERT_GE (slabStats.approxFreePercent ,10 );
119121 }
120122
121123 void testMultiTiersValidMixed () {
0 commit comments