@@ -6417,10 +6417,13 @@ TEST_P(RoundRobinSubcompactionsAgainstPressureToken, PressureTokenTest) {
6417
6417
options.level0_file_num_compaction_trigger = 4 ;
6418
6418
options.target_file_size_base = kKeysPerBuffer * 1024 ;
6419
6419
options.compaction_pri = CompactionPri::kRoundRobin ;
6420
- // Target size is chosen so that filling the level with `kFilesPerLevel` files
6421
- // will make it oversized by `kNumSubcompactions` files.
6420
+ // Pick a small target level size so that round-robin compaction will pick
6421
+ // more files to compact and trigger subcompactions. Actual number of
6422
+ // subcompactions will be limited by number of bg threads available.
6423
+ // Cannot be too small to cause compaction pressure. See
6424
+ // GetPendingCompactionBytesForCompactionSpeedup().
6422
6425
options.max_bytes_for_level_base =
6423
- (kFilesPerLevel - kNumSubcompactions ) * kKeysPerBuffer * 1024 ;
6426
+ (kFilesPerLevel - 10 ) * kKeysPerBuffer * 1024 ;
6424
6427
options.disable_auto_compactions = true ;
6425
6428
// Setup `kNumSubcompactions` threads but limited subcompactions so
6426
6429
// that RoundRobin requires extra compactions from reserved threads
@@ -6446,21 +6449,34 @@ TEST_P(RoundRobinSubcompactionsAgainstPressureToken, PressureTokenTest) {
6446
6449
ASSERT_EQ (kFilesPerLevel , NumTableFilesAtLevel (lvl, 0 ));
6447
6450
}
6448
6451
6452
+ bool compaction_num_input_file_verified = false ;
6453
+ SyncPoint::GetInstance ()->SetCallBack (
6454
+ " LevelCompactionPicker::PickCompaction:Return" , [&](void * arg) {
6455
+ if (!compaction_num_input_file_verified) {
6456
+ Compaction* compaction = static_cast <Compaction*>(arg);
6457
+ // In Round-Robin, # of subcompactions needed is the # of input files
6458
+ ASSERT_GT (compaction->num_input_files (0 ), 1 );
6459
+ compaction_num_input_file_verified = true ;
6460
+ }
6461
+ });
6462
+
6449
6463
// This is a variable for making sure the following callback is called
6450
6464
// and the assertions in it are indeed excuted.
6451
6465
bool num_planned_subcompactions_verified = false ;
6452
6466
ROCKSDB_NAMESPACE::SyncPoint::GetInstance ()->SetCallBack (
6453
6467
" CompactionJob::GenSubcompactionBoundaries:0" , [&](void * arg) {
6454
- uint64_t num_planned_subcompactions = *(static_cast <uint64_t *>(arg));
6455
- if (grab_pressure_token_) {
6456
- // `kNumSubcompactions` files are selected for round-robin under auto
6457
- // compaction. The number of planned subcompaction is restricted by
6458
- // the limited number of max_background_compactions
6459
- ASSERT_EQ (num_planned_subcompactions, kNumSubcompactions );
6460
- } else {
6461
- ASSERT_EQ (num_planned_subcompactions, 1 );
6468
+ if (!num_planned_subcompactions_verified) {
6469
+ uint64_t num_planned_subcompactions = *(static_cast <uint64_t *>(arg));
6470
+ if (grab_pressure_token_) {
6471
+ // `kNumSubcompactions` files are selected for round-robin under
6472
+ // auto compaction. The number of planned subcompaction is
6473
+ // restricted by the limited number of max_background_compactions
6474
+ ASSERT_EQ (num_planned_subcompactions, kNumSubcompactions );
6475
+ } else {
6476
+ ASSERT_EQ (num_planned_subcompactions, 1 );
6477
+ }
6478
+ num_planned_subcompactions_verified = true ;
6462
6479
}
6463
- num_planned_subcompactions_verified = true ;
6464
6480
});
6465
6481
6466
6482
// The following 3 dependencies have to be added to ensure the auto
0 commit comments