@@ -9915,6 +9915,20 @@ static void VerifyTemperatureFileReadStats(const Statistics& st,
99159915 EXPECT_EQ (iostats->file_io_stats_by_temperature .warm_file_read_count , 0 );
99169916 }
99179917
9918+ if (temps.Contains (Temperature::kCool )) {
9919+ EXPECT_GE (st.getTickerCount (COOL_FILE_READ_BYTES ), min_bytes);
9920+ EXPECT_GE (st.getTickerCount (COOL_FILE_READ_COUNT ), min_count);
9921+ EXPECT_GE (iostats->file_io_stats_by_temperature .cool_file_bytes_read ,
9922+ min_bytes);
9923+ EXPECT_GE (iostats->file_io_stats_by_temperature .cool_file_read_count ,
9924+ min_count);
9925+ } else {
9926+ EXPECT_EQ (st.getTickerCount (COOL_FILE_READ_BYTES ), 0 );
9927+ EXPECT_EQ (st.getTickerCount (COOL_FILE_READ_COUNT ), 0 );
9928+ EXPECT_EQ (iostats->file_io_stats_by_temperature .cool_file_bytes_read , 0 );
9929+ EXPECT_EQ (iostats->file_io_stats_by_temperature .cool_file_read_count , 0 );
9930+ }
9931+
99189932 if (temps.Contains (Temperature::kCold )) {
99199933 EXPECT_GE (st.getTickerCount (COLD_FILE_READ_BYTES ), min_bytes);
99209934 EXPECT_GE (st.getTickerCount (COLD_FILE_READ_COUNT ), min_count);
@@ -9945,7 +9959,7 @@ static void VerifyTemperatureFileReadStats(const Statistics& st,
99459959}
99469960
99479961TEST_F (DBCompactionTest, FIFOMultiTierTemperatureAging) {
9948- // Test multi-tier aging: Hot -> Warm -> Cold -> Ice
9962+ // Test multi-tier aging: Hot -> Warm -> Cool -> Cold -> Ice
99499963 Options options = CurrentOptions ();
99509964 options.compaction_style = kCompactionStyleFIFO ;
99519965 options.num_levels = 1 ;
@@ -9961,8 +9975,9 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
99619975 // Multi-tier aging: files age through multiple temperatures
99629976 fifo_options.file_temperature_age_thresholds = {
99639977 {Temperature::kWarm , 500 }, // Hot -> Warm after 500s
9964- {Temperature::kCold , 1000 }, // Warm -> Cold after 1000s
9965- {Temperature::kIce , 1500 } // Cold -> Ice after 1500s
9978+ {Temperature::kCool , 1000 }, // Warm -> Cool
9979+ {Temperature::kCold , 1500 }, // Cool -> Cold
9980+ {Temperature::kIce , 2000 } // Cold -> Ice
99669981 };
99679982 fifo_options.max_table_files_size = 100000000 ;
99689983 fifo_options.allow_trivial_copy_when_change_temperature = true ;
@@ -9973,8 +9988,8 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
99739988 env_->SetMockSleep ();
99749989
99759990 // Track all temperature file creations
9976- int total_hot = 0 , total_warm = 0 , total_cold = 0 , total_ice = 0 ,
9977- total_unknown = 0 ;
9991+ int total_hot = 0 , total_warm = 0 , total_cool = 0 , total_cold = 0 ,
9992+ total_ice = 0 , total_unknown = 0 ;
99789993 ROCKSDB_NAMESPACE::SyncPoint::GetInstance ()->SetCallBack (
99799994 " NewWritableFile::FileOptions.temperature" , [&](void * arg) {
99809995 Temperature temperature = *(static_cast <Temperature*>(arg));
@@ -9985,6 +10000,9 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
998510000 case Temperature::kWarm :
998610001 total_warm++;
998710002 break ;
10003+ case Temperature::kCool :
10004+ total_cool++;
10005+ break ;
998810006 case Temperature::kCold :
998910007 total_cold++;
999010008 break ;
@@ -10016,8 +10034,11 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
1001610034
1001710035 VerifyTemperatureFileReadStats (*options.statistics , Temperature::kHot );
1001810036
10037+ // Land well into each time interval
10038+ env_->MockSleepForSeconds (100 );
10039+
1001910040 // Age initial files to warm
10020- env_->MockSleepForSeconds (600 );
10041+ env_->MockSleepForSeconds (500 );
1002110042 ASSERT_OK (Put (Key (1 ), Random::GetTLSInstance ()->RandomBinaryString (101 )));
1002210043 ASSERT_OK (Flush ());
1002310044 ASSERT_OK (dbfull ()->TEST_WaitForCompact ());
@@ -10031,12 +10052,26 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
1003110052 // Verify Warm file statistics
1003210053 VerifyTemperatureFileReadStats (*options.statistics , Temperature::kWarm );
1003310054
10034- // Age initial files to cold
10035- env_->MockSleepForSeconds (600 );
10055+ // Age initial files to cool
10056+ env_->MockSleepForSeconds (500 );
1003610057 ASSERT_OK (Put (Key (2 ), Random::GetTLSInstance ()->RandomBinaryString (102 )));
1003710058 ASSERT_OK (Flush ());
1003810059 ASSERT_OK (dbfull ()->TEST_WaitForCompact ());
1003910060
10061+ // Test reading from Cool temperature file (the aged file)
10062+ ASSERT_OK (options.statistics ->Reset ());
10063+ get_iostats_context ()->Reset ();
10064+
10065+ ASSERT_EQ (100U , Get (Key (0 )).size ());
10066+
10067+ VerifyTemperatureFileReadStats (*options.statistics , Temperature::kCool );
10068+
10069+ // Age initial files to cold
10070+ env_->MockSleepForSeconds (500 );
10071+ ASSERT_OK (Put (Key (3 ), Random::GetTLSInstance ()->RandomBinaryString (103 )));
10072+ ASSERT_OK (Flush ());
10073+ ASSERT_OK (dbfull ()->TEST_WaitForCompact ());
10074+
1004010075 // Test reading from Cold temperature file (the aged file)
1004110076 ASSERT_OK (options.statistics ->Reset ());
1004210077 get_iostats_context ()->Reset ();
@@ -10046,8 +10081,8 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
1004610081 VerifyTemperatureFileReadStats (*options.statistics , Temperature::kCold );
1004710082
1004810083 // Age initial files to ice
10049- env_->MockSleepForSeconds (600 );
10050- ASSERT_OK (Put (Key (3 ), Random::GetTLSInstance ()->RandomBinaryString (103 )));
10084+ env_->MockSleepForSeconds (500 );
10085+ ASSERT_OK (Put (Key (4 ), Random::GetTLSInstance ()->RandomBinaryString (104 )));
1005110086 ASSERT_OK (Flush ());
1005210087 ASSERT_OK (dbfull ()->TEST_WaitForCompact ());
1005310088
@@ -10072,12 +10107,14 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
1007210107 // Verify current files temperatures
1007310108 EXPECT_EQ (temp_counts[Temperature::kHot ], 1 );
1007410109 EXPECT_EQ (temp_counts[Temperature::kWarm ], 1 );
10110+ EXPECT_EQ (temp_counts[Temperature::kCool ], 1 );
1007510111 EXPECT_EQ (temp_counts[Temperature::kCold ], 1 );
1007610112 EXPECT_EQ (temp_counts[Temperature::kIce ], 3 );
1007710113
1007810114 // Verify historical (and current) file temperatures
10079- EXPECT_EQ (total_hot, 6 );
10080- EXPECT_EQ (total_warm, 5 );
10115+ EXPECT_EQ (total_hot, 7 );
10116+ EXPECT_EQ (total_warm, 6 );
10117+ EXPECT_EQ (total_cool, 5 );
1008110118 EXPECT_EQ (total_cold, 4 );
1008210119 EXPECT_EQ (total_ice, 3 );
1008310120
@@ -10087,7 +10124,7 @@ TEST_F(DBCompactionTest, FIFOMultiTierTemperatureAging) {
1008710124 get_iostats_context ()->Reset ();
1008810125
1008910126 // Read from all files to verify cumulative statistics
10090- for (int i = 0 ; i < 4 ; i++) {
10127+ for (int i = 0 ; i < 5 ; i++) {
1009110128 ASSERT_EQ (static_cast <unsigned >(100 + i), Get (Key (i)).size ());
1009210129 }
1009310130
0 commit comments